I have my dedicated server which is from CA, USA. When I use sql query for any datetime fields, it always return USA timezone in result. Is it possible to retrieve date in our local format like Indian date and time by using sql query?Any help appreciated.
Hi Haresh, its possible but there might be small variation to display exact time. I have used following query and I am able to get IST time format with date as well.
select switchoffset(sysdatetimeoffset(), '+05:30')
2019-01-18 16:26:07.0848913 +05:30
SELECT switchoffset(GetDate(), '+05:30')
2019-01-18 17:27:30.787 +05:30
Both sql used for same purpose but still we can see minor variation in time. You may use it as per you need and add tweak as well if needed.
I hope this helps you.