LINQ DateTime Format
-
Im converting all code from ADO.net to LINQ. In ADO i could add a DateTime field into SQL when adding a record. Im doing the same with LINQ & im getting an error. SqlDateTime Overflow. Must be between 1/1/1753 12:00:00 AM AND 12/31/9999 11:59:59 PM. My format is 2008/11/03 11:00:00 AM. How can I make it take this format & store it in sql server as the required format & not throw this error ?
-
Im converting all code from ADO.net to LINQ. In ADO i could add a DateTime field into SQL when adding a record. Im doing the same with LINQ & im getting an error. SqlDateTime Overflow. Must be between 1/1/1753 12:00:00 AM AND 12/31/9999 11:59:59 PM. My format is 2008/11/03 11:00:00 AM. How can I make it take this format & store it in sql server as the required format & not throw this error ?
There is no standard date format that looks like that. Try the ISO 8601 format "2008-11-03 11:00:00" instead. Otherwise you would have to use the DateTime.ParseExact method with the date format "yyyy/MM/dd HH:mm:ss" to parse the string into a DateTime value.
Despite everything, the person most likely to be fooling you next is yourself.
-
There is no standard date format that looks like that. Try the ISO 8601 format "2008-11-03 11:00:00" instead. Otherwise you would have to use the DateTime.ParseExact method with the date format "yyyy/MM/dd HH:mm:ss" to parse the string into a DateTime value.
Despite everything, the person most likely to be fooling you next is yourself.