954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Get Indian Standard Time in Sql server 2005

Hi,

I want to get Indian Standard Time (IST) in Sql Server 2005. How can I achieve this?

Note:

SELECT 'SYSDATETIMEOFFSET', SYSDATETIMEOFFSET() this query works fine in Sql server 2008. Is there any option in Sql Server 2005?

Thanks in Advance

visweswaran28
Light Poster
35 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Sort of.

There are several datetime system functions common to prior releases of SQL Server. GetDate() gives local date/time. GetUTCDate() gives GMT. You can then use datediff to find the hour difference between them to give you the offset, like so:

select datediff(hh,  getutcdate(), getdate())


So for me here in California, the offset is -8. For you in India, I would guess it's more like +5 or so.

MS simply added a new system datetime function to give you all the parts in one easy-to-use function, SYSDATETIMEOFFSET().

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You