I have SQL Server 2008 R2 and one of my tables has a date field. When an insert from my ASP.NET page happens, the date is automatically inserted by setting the default field value to getdate(). However, this adds the date in the format YYYY-MM-DD HH:MM:SS.0000000. I really only need the time up to seconds and not the trailing zeros after it.
How can I do this?
A
DateTime, whether in SQL Server or .NET code does not have a format. It has an internal representation.When you want to display the value of the
DateTimeyou format it using a format string.