Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server UTC to local time

Tags:

sql

sql-server

is there a function in SQL Server, which returns difference between UTC time and local time of the server?

like image 466
eba Avatar asked Apr 11 '26 21:04

eba


1 Answers

If you're using SQL 2008, then using the datetimeoffset type and related functions are much better. But assuming you're talking about the current offset, you could do something like:

DATEDIFF(minute, GETUTCDATE(), GETDATE())
like image 130
Josh Avatar answered Apr 14 '26 21:04

Josh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!