How to convert Date and time in IST in SQL ServerAsk Questions

 Posted on 05/01/2019 8:24:10 AM

I have my dedicated server which is from CA, USA. When I use sql query for any datetime fields, it always return USA timezone in result. Is it possible to retrieve date in our local format like Indian date and time by using sql query?

Any help appreciated.

Thanks

Share On: facebook gplus twitter
profile
Asked by Haresh Chaudhari on 05/01/2019 8:24:10 AM Score: 315 points
Add Comment:
Submit

Comments

1 Answer

1 Corrected Answers
Aproved Answers
1
Profile
Answered by Narendra Shah on Jan 18 2019 11:58AM Score: 98 points

Hi Haresh, its possible but there might be small variation to display exact time. I have used following query and I am able to get IST time format with date as well.

select switchoffset(sysdatetimeoffset(), '+05:30')

Output:

2019-01-18 16:26:07.0848913 +05:30

 

SELECT switchoffset(GetDate(), '+05:30')

Output:

2019-01-18 17:27:30.787 +05:30

 

Both sql used for same purpose but still we can see minor variation in time. You may use it as per you need and add tweak as well if needed.

I hope this helps you.

Thank you

 

Add Comment:

Post Your Answer

  •  
  •  

Existing Members

Sign in to your account
Email Address
Password
...or Join us
Download, Vote, Comment, Publish.
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.