Results 1 to 2 of 2

Thread: Time data type in vba

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Post Thanks / Like
    7 Post(s)
    0 Thread(s)

    Default Time data type in vba

    The code below worsk but I wonder why vBA does not have Time type. Is not Date and Time format different?
    I defined x here as a Date but then assign Time function to it. It did work but wondering why there is not Time type. Thank you very much

    Sub mytime()
        Dim xtime As Date
        xtime = Time
        MsgBox xtime
    End Sub

  2. #2
    MrExcel MVP
    Join Date
    May 2009
    Post Thanks / Like
    39 Post(s)
    9 Thread(s)

    Default Re: Time data type in vba

    Time is the part of the serial date number that indicates what fraction of the current day has elapsed. At noon today the serial date number is 43747.5 which can be formatted to: 10/9/2019 12:00 PM

    When I was a young man I knew everything. Now that I'm older, I realize I know very little, and what I do know, I tend to forget!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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