Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

17 Date-Time


'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