We would like to get the date in a specific location, either by using something like the C# solution:
TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "West US Time");
Or by setting the Azure SQL Database timezone and then using getdate().
From MSDN: Use AT TIME ZONE
SELECT CONVERT(datetime, '03/29/2015 01:01:00')
AT TIME ZONE 'Central European Standard Time';
--2015-03-29 01:01:00.000 +01:00
--Time between 02:00 and 03:00 is converted as +01!
SELECT CONVERT(datetime, '03/29/2015 02:01:00')
AT TIME ZONE 'Central European Standard Time';
--2015-03-29 02:01:00.000 +01:00
SELECT CONVERT(datetime, '03/29/2015 03:01:00')
AT TIME ZONE 'Central European Standard Time';
--2015-03-29 03:01:00.000 +02:00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With