How to convert datetime value to double in access and SQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravencrt
    New Member
    • Jan 2011
    • 1

    How to convert datetime value to double in access and SQL?

    Hello
    I have a problem and I don't know how to sort it out. Why when I convert a date value to double in access vba I receive a value and when I convert the same data value to decimal in sql I receive a diferent value.

    Example:
    Access vba
    Code:
    dim data as date
    data=date (today is 04/01/2011)
    msgbox(cdbl(data))
    The resuls of this code is 40547

    SQL
    Code:
    set dateformat 'dmy'
    seclare @data datetime, @variabila decimal
    set @data='04/01/2011'
    set @variabila=convert(decimal,@data)
    print @variabila
    the result returned is 40545

    I realy don't understand why is this happening, in my opinion it should return the same result in both cases.
  • Selun
    New Member
    • Jan 2011
    • 6

    #2
    Edit.
    Sorry for hijacking, i had no clue.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Ravenort, Access stores dates using 12/30/1899 as the origin point. Meaning that 12/30/1899 is 0. Why they chose to do this, I do not know. Whichever DBMS you're using stores dates using 1/1/1900 as the origin point.

      Selun, start your own thread, don't hijack this one.

      Comment

      Working...