MsgBox Date
' show the time
MsgBox Time
' show both the date and time
MsgBoxNow
' calculate the minimum Date of Birth for someone who is 18 years old
strMinDoB = DateAdd("yyyy", -18, Date)
MsgBox strMinDob
' show the number of years difference between strMinDob and today
MsgBox DateDiff("yyyy", strMinDob, Date)
' show the hour portion of the time
MsgBox DatePart("h", Time)
' show the day portion of the date
MsgBox Day(strMinDob)
' show the month portion of the date
MsgBox Month(strMinDob)
' show the year portion of the date
MsgBox Year(strMinDob)
' show the weekday portion of the date
' Sunday=1, Monday=2, --> Saturday=7
MsgBox WeekDay(strMinDob)
Note: Acceptable 'Interval' parameters for DatePart, DateAdd and DateDiff...
"yyyy" = Year
"q" = Quarter
"m" = Month
"y" = Day of year
"d" = Day
"w" = Weekday
"ww" = Week of year
"h" = Hour
"n" = Minute
"s" = Second
Tuesday, 18 October 2011
Some date manipulation functions.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment