This seems like it should be really obvious, but how can I put a DateTime object into an MSSQL database? When I convert it to a string, it keeps adding “-7:00” at the end for the time zone offset and so the query isn’t accepted. How can I fix this?
Share
How are you trying to insert the
DateTimeinto the database? If you’re converting it to a string to be passed into a stored procedure (bad idea; better to use the date SQL type), then you should first convert allDateTimeobjects to UTC using the .net methodToUniversalTime. Once in UTC, theDateTimewill have no timezone offset.