In my web application, all date values ββare converted to UTC before being transferred to the SQL database, and then converted back to local time when they are displayed in the application. Therefore, the bottom line indicates that all dates are in UTC in the database.
This worked fine until I started developing the report. In Crystal Reports there is no way (I can detect) to convert the time zone, so I need to do the conversion to SQL before passing the value to the report.
SQL Server seems to have a much more limited ability to convert date and time values. The only function I see is SWITCHOFFSET. The problem with this function is that it does not know about daylight, which, apparently, is the main disadvantage. In asp.net, I can pass a datetime value with a time zone, and it will automatically convert it to UTC, taking into account any necessary daylight saving settings.
In SQL though, instead of saying something like
SWITCHOFFSET (SomeDate,"Eastern Time"),
Now i have to say
SWITCHOFFSET(SomeDate, "-4:00").
But what happens if I pull out the data from the table and I ask for all the data for March, the month when the daylight saving time starts? Regardless, some of them will be wrong. I can say: -4: 00 or -5: 00, but obviously not both.
Is there any other function for this, since, frankly, it seems that SWITCHOFFSET is half-baked if it does not know how to make daylight saving.