Search Tools Links Login

GBIC: Date and Time


Visual Basic 6, or VB Classic

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.


'VB supports a Date data type
Dim D1 As Date , D2 As Date
NumberDays = D2 - D1 'subtracting dates gives days (Single data type)

'Functions
iResults = Second(DateVar) 'returns 1-59
iResults = Minute(DateVar) 'returns 1-59
iResults = Hour(DateVar) 'returns 1-23
iResults = Day(DateVar) 'returns 1-31
iResults = Month(DateVar) 'returns 1-12
iResults = Weekday(DateVar) 'returns 1-7
iResults = Year(DateVar) 'returns 4 digit year

'Set time/date
Time = TimeString
Date = DateString

'Get time/date
DateVar = Date
TimeVar = Time

'Time Operations
DateAdd
DateDiff
DatePart

'Time Functions
DateSerial
DateValue
TimeSerial
TimeValue

About this post

Posted: 2021-02-11
By: ArchiveBot
Viewed: 163 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.