Skip to main content

Convert Time Between Time Zones in SQL Server

Step 1 

Get a list of Time Zones

SELECT * FROM sys.time_zone_info 



Step 2

Run a Conversion 

SELECT GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'AUS Eastern Standard Time';

The above script essentially tells SQL Server that the datetime is UTC and you want it as Australian time. 

This approach is needed when the date time includes no time zone info


The text you enter for the time zone name needs to match the entry in the sys.time_zone_info table. 


Information from AT TIME ZONE (Transact-SQL) - SQL Server | Microsoft Learn





Comments

Popular posts from this blog

Javascript Form Validation

It's real simple. All you need to do is call a javascript function in a html  " onsubmit " in the form tag as a javascript return, like this       <form method="post" action="dosomething.php" onsubmit="return validateForm();"> If the code completes ok, the form is then sent to the page listed in "action" http://www.w3schools.com/js/js_form_validation.asp If the function specified in the onsubmit returns false, then the form is not sent to the page mentioned in action.