DatePart: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
<pre> | <pre> | ||
Rem DatePart Example | |||
'DatePart returns a numberfrompartofadate | 'DatePart returns a numberfrompartofadate | ||
Dim QuarterPart, MonthPart, DayPart | |||
QuarterPart = DatePart("q", | QuarterPart = DatePart("q", Now) | ||
MonthPart = DatePart("m", | MonthPart = DatePart("m", Now) | ||
DayPart = DatePart("d", | DayPart = DatePart("d", Now) | ||
Print "Today is day " & DayPart | |||
Print "of month " & MonthPart | |||
Print "in quarter " & QuarterPart | |||
</pre> | </pre> | ||
| Line 30: | Line 30: | ||
== Related Items == | == Related Items == | ||
[[dateadd| | [[dateadd|DateAdd]], [[datediff|DateDiff]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
Revision as of 00:31, 24 August 2012
DatePart(interval, date[, firstdayofweek[, firstweekofyear]])
Description
DatePart returns a number specifying a part of the given date. The required parameter, interval, determines the part of date which is measured and returned. The optional parameter firstdayofweek is Sunday, if not specified The optional firstweekofyear is the week containing January 1, if not specified.
Example
Rem DatePart Example
'DatePart returns a numberfrompartofadate
Dim QuarterPart, MonthPart, DayPart
QuarterPart = DatePart("q", Now)
MonthPart = DatePart("m", Now)
DayPart = DatePart("d", Now)
Print "Today is day " & DayPart
Print "of month " & MonthPart
Print "in quarter " & QuarterPart
Output
Today is day 18
of month 8
in quarter 3
(''sample output from August 18, 1998'')