tags:

views:

27

answers:

1

how to get the exact OmanTime using an sql function?

This is my code : RETURN DATEADD(mi,-90,@CurrentDate)

but it is not correct.

+1  A: 

Muscat, Oman in is the +4 timezone, so local time there is 4 hours later than UTC - thus, when it's noon on the zero meridian it's 4:00 PM in Muscat. Thus, you'd need to do something like

RETURN DATEADD(Hour, 4, GETUTCDATE())

Share and enjoy.

Bob Jarvis
Note that this only works because that timezone has no daylight savings time. For timezones that do, it gets rather more complex.
Michael Borgwardt
SELECT DATEADD(Hour, 4, GETUTCDATE()) will work,but RETURN DATEADD(Hour, 4, GETUTCDATE()) is not working.The error message is "Invalid use of 'getutcdate' within a function"
Adu
SELECT DATEADD(Hour, 4, GETUTCDATE()) will work,but RETURN DATEADD(Hour, 4, GETUTCDATE()) is not working. The error message is "Invalid use of 'getutcdate' within a function"
Adu