DatePart Help needed urgently!!!!

  • hello guys, well this time its a problem for datepart function well our one server is lying in Michigan and the other i.e. local server is lying here in india, now the problem is of time i.e. the time of michigan is 10 hours late e.g. when its 25th November 11:OO:AM here the time over there in michigan is (24th November ) so when we want to display the records we r getting problems our customers are shouting ..

    so timely help will save my job

    plz reply fast ASAP

    Thank u

    Keyur

  • Take a look at the GETUTCDATE() function - this would let you convert both times to a common standard before doing the datediff or whatever.

    Andy

  • Andy where do i look for the GETUTCDATE() function tried BOL but no help i found there.

    thanks for the reply

    keyur

  • You must be using SQL7? I'll have to check, don't have BOL for 7 here.

    Andy

  • Can you determine the source of data? If so, then modify the date with a dateadd() function.

    I know this is kludgy, but you will need to deal with this somewhere. You also may want to create a table with a row for India and one for MI and join with this table for the dateadd() function. This will allow you to grow if you add a server in CA, or UK, etc.

    Steve Jones

    steve@dkranch.net

  • THANKS, andy and steve for ur quick responses, yes i am using sql 7.0

    and steve i am not clear about ur suggestion. u mean to say that i should create two different tables and then join them... if u could plz elaborate ur idea it would be helpful.

    thanks once again for ur responses

    keyur

  • If you have a table,

    MyTable( MyID, MyDate, Source)

    that has some data:

    MyID MyDate Source

    ------ ---------------- ----------

    1 11/01/01 4:00pm India

    2 11/02/01 11:00am MI,USA

    3 11/01/01 5:00pm India

    4 11/02/01 12:00pm MI,USA

    and another table:

    MyTime(Location, Diff)

    with:

    Location Diff

    ----------- ------

    India 0

    Mi,USA 11

    then you can join these two tables liek this:

    select a.MyID

    , dateadd( hour, b.Diff, a.MyDate)

    from MyTable a

    inner join MyTime b

    on b.Location = a.Source

    Steve Jones

    steve@dkranch.net

  • When we first had this problem we decided to store all system dates in GMT and convert them to the user's local time. As long as the servers are synchronized to a relatively close system time, this problem becomes moot.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply