Wednesday, December 16, 2020

Getting Local Date Time in SQL Server Database

When we work on cloud database, default function for getting current date time gives UTC date time. So for getting local date time we should create a scalar valued function using following script, so that it can be using seamlessly where ever needed..


SELECT CONVERT(DATETIME, GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'India Standard Time')

 

Above script will give India Standard Time DateTime.

No comments:

Post a Comment