Results 1 to 2 of 2

Thread: Datetime

  1. #1
    Join Date
    Feb 2002
    Location
    India
    Posts
    15

    Unanswered: Datetime

    Hi

    I have read that in sqlserver the date takes 4 bytes for no. of days
    before or after the base date and another 4 bytes for the no. of
    milliseconds.

    But when I convert the date into a float and try to correlate the
    decimal part with the no. of milliseconds, I am totally lost.

    Moreover, in Inside Sql Server 2000 book by Delaney the following is mentioned ( not verbatim ) ,

    declare @dt datetime
    select @dt = getdate()
    select convert(int,substring(varbinary(8),@dt),5,4))

    What is this number going to represent? Given a datetime I need to know how many seconds have elapsed from midnight ( from the time part ).

    Thanks

    Joe

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    maybe somthing like this?

    set nocount on
    select datepart(hh,getdate())
    , datepart(mi,getdate())
    , datepart(ss,getdate())
    , datepart(ms,getdate())
    , getdate()
    select (datepart(hh,getdate())*60*60)
    , (datepart(mi,getdate())*60)
    , datepart(ss,getdate())
    , datepart(ms,getdate())
    , getdate()
    select (datepart(hh,getdate())*60*60) +
    (datepart(mi,getdate())*60) +
    datepart(ss,getdate())
    , datepart(ms,getdate())
    , getdate()
    Paul Young
    (Knowledge is power! Get some!)

Posting Permissions

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