Microsoft Access VBA Macro Programming

(Tina Sui) #1

Month


Monthreturns an integer between 1 and 12, based on the date expression:


Month (dateexpression)


An example of adateexpressioncould be “31-Dec-2002 12:00” or could be a time without
the date, such as “09:00.”
The following will both return the value of 3 because both date expressions represent
6-Mar-2003:


Msgbox Month( 37686 )
Msgbox Month("6-Mar-2003")


Second


TheSecondfunction returns an integer between 0 and 59 based on thetimeexpression
representing the seconds of a minute:


Second(timeexpression)


An example of atimeexpressioncould be “31-Dec-2002 12:00” or could be a time without
the date, such as “09:00.”
The following will return the value 48:


Msgbox Second("4:35:4 8 pm")


Minute


TheMinutefunction returns an integer from a time expression representing the actual minute
of that time.


Msgbox Minute(11.27 / 24)


This will return the value 16, since 11.27 is 11:16:12 a.m. This may look confusing because
we are dealing with decimal parts of an hour. The expression 11.27 is a decimal of an hour,
so .27 is just over a quarter of an hour.
Following are two examples of theMinutefunction:


Msgbox Minute("4:35pm")
Msgbox Minute(11.25 / 24)


Year


TheYearfunction returns an integer from a date expression representing the actual year
value of that date:


Msgbox Year( 37686 )
Msgbox Year("6-Mar-2003")


Chapter 5: Strings, Functions, and Message Boxes 61

Free download pdf