Results 1 to 3 of 3

Thread: Probably Dead Easy, Convert Date to Decimal

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Red face

    I am sure this is easy to do, but what's the easiest way to convert a date into it's decimal equivalent.

    i.e. 6:45 = 6.75 etc....

    I know I could just frig it using math formulas but is there a built in VB function as I can't seem to find one.

    Thanks For any help
    Steve

  2. #2
    Guest
    Have a go with this formula...

    Code:
    Public Function TimeToDec(Dat As Date) As Single
        TimeToDec = Hour(Dat) + ((1 / 60) * Minute(Dat)) + ((1 / 6000) * Second(Dat))
    End Function
    I'm not sure abaut the seconds-part then...

    Try this for minute-precsion:

    Code:
    Public Function TimeToDec(Dat As Date) As Single
        TimeToDec = Hour(Dat) + ((1 / 60) * Minute(Dat)) 
    End Function
    Enjoy!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Thumbs up Cheers

    Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width