Reputation: 2157
I have a table in the Azure SQL Database like below
I need to what day is today and compare against the OrderDay field. I was thinking I could do something like below in the where clause
SUBSTRING(DATENAME(weekday,GETDATE()), 0, 4)
There are is an issue with it when I added this in the select
Though I am running it today where I am still in the CST timezone its still Monday here and the Azure DB is located in EAST US but it is returning Tue.
Upvotes: 0
Views: 104
Reputation: 5074
Azure SQL Database always follows UTC time zone.
Use AT TIME ZONE to convert it to CST or another non-UTC time zone.
Use the below syntax to get the day information in the CST time zone using AT TIME ZONE
SUBSTRING(DATENAME(weekday,getdate() AT TIME ZONE 'UTC' AT TIME ZONE 'Central Standard Time'), 0, 4)
You can also refer sys.time_zone_info view to check current utc offset information.
select * from sys.time_zone_info
Upvotes: 1