Calculating number of seconds

  • Hi,

    I am in need of a logic to find out the number of seconds (in Indian Time) between 2 given dates. The server is having the time of US as it is sitting in Texas.

    Will appreciate if anybody can help me out.


    Lucky

  • Please explain what Indian time is.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • I suppose you mean e.g. you have used us-insert time of a row and now you want to calculate the insert delay (network) ?

    maybe test this script :

    set nocount on

    create table #mytable (MyInsertDtTs datetime not null default getdate()

    , myothercol varchar(128) not null

    , myLocalDtTs datetime not null

    )

    declare @myLocalDtTs datetime

    set @myLocalDtTs = getdate()

    -- WAITFOR DELAY '000:00:10'

    insert into #mytable (myothercol, myLocalDtTs) values('this is my text', @myLocalDtTs)

    -- Your local time in india = gmt + 8

    -- US time is gmt - 7

    -- timediff = 15 hours

    select datediff(ss,MyInsertDtTs,dateadd(hh,-15,myLocalDtTs)) as ElapsSeconds

    , MyInsertDtTs

    , myLocalDtTs

    , dateadd(hh,-15,myLocalDtTs) as myLocalDtTs_2_ServerDtTs

    from #mytable

     drop table #mytable

    I hope this helps

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • IIRC, you might also want to search the script archive here. James Travis (aka Antares686) has posted such a script. It should help you.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

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