Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2016
    Posts
    2

    Question Unanswered: Convert System Time to UTC

    Hello Team,

    I have written below script:
    Declare @baseline_start_time time = null
    set @baseline_start_time ='hh:mm:ss'

    My application gives me IST Timestamp whereas all time on Server is from GMT (UTC). So every time as per the requirement I have to convert the IST to GMT manually and provide to fetch the details. Now I want something where I will provide my system timestamp, but the user's input should automatically change to UTC and fetch the required result.

    Please help!

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Why not use the function GETUTCDATE()?

  3. #3
    Join Date
    Apr 2016
    Posts
    2

    Lightbulb

    Quote Originally Posted by srikantnayak View Post
    Hello Team,

    I have written below script:
    Declare @baseline_start_time time = null
    set @baseline_start_time ='hh:mm:ss'

    My application gives me IST Timestamp whereas all time on Server is from GMT (UTC). So every time as per the requirement I have to convert the IST to GMT manually and provide to fetch the details. Now I want something where I will provide my system timestamp, but the user's input should automatically change to UTC and fetch the required result.

    Please help!


    So if I use the below, will I be able to provide IST time and it would fetch required data from DB?
    Declare @baseline_start_time time = getutcdate()

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    That is going to depend heavily on whether you need to deal with any Daylight Savings scheme. If you do, you may find it generally easier to store both times, and use one or the other depending on what process you are running.

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    As far as I know, IST has never observed DST. The delta from IST to UTC is always +330 minutes.

    Without understanding all of the details of your requirements, I don't know how to give you a simple answer. For example, if you know that your application will only be used at 00:05 IST, you can hard code the time as 18:35 the prior day. This isn't really useful, because I would expect that your code would be used more than one minute per day.

    Every operating system and almost every programming language exposes UTC. Without details about what you're doing and the tools that you're using I can't give you examples, but I'm pretty sure that those examples do exist somewhere on the internet. I would be willing to wager that you've already spent more time trying to find a "simple" answer than it would take you to understand and automate the conversion so that you get the correct data every time and understand any weaknesses in your implementation that might cause you pain later!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •