Saturday, October 1, 2011

DateTime Manipulation in SQL – Convert Universal time to local time


There are many datetime manipulation functions available in sql server , we will look at it one by one in this series of "DateTime Manipulation in SQL".

You all are aware of UTC which stands for Universal Time Coordinated , some are also known as GMT which stands for Greenwhich Mean Time , this are standard date & time , we can get our local time by adding offset to it (e.g for india it is +5:30).

At time of building query in SQL you need to convert UTC time local time, and you can do it following way

getutcdate() return UTC datetime


getdate() return local datetime (as per your system configuration)


dateadd() function is to add parts (hour, day, minute etc..) to any datetime object.


No comments: