I use GETDATE() in a SQL Server stored procedure to insert a date into the SQL Server database table.
After that I need to implement a C# function which is based on datetime input parameter finds if the date was saved in the tables.
The datetime in C# and SQL are different. How do I convert from C# datetime to SQL datetime which has a form of yyyy-mm-ddT:yy:mm:ss.mmm? I need to specify explicitly yyyy-mm-ddT:yy:mm:ss.mmm.
Will be happy for all propositions/possible ways.
DATETIMEin T-SQL andDateTimein .NET are not different - you can represent anyDATETIMEin SQL Server as a .NETDateTime.DATETIMEin SQL Server has limits in terms of range (1-Jan-1753 to 31-Dec-9999) and accuracy (3.33ms) but it's deprecated in SQL Server 2008 anyway and shouldn't be used anymore; useDATE(if you only need date - no time) orDATETIME2(n)instead