Tuesday, October 20, 2009

The DatePart Function


The DatePart Function in VB6,
The generic DatePart function returns an Integer containing the specified part of a given date/time value. Thus, it incorporates the functionality of the Weekday, Month, Day, Year, Hour, Minute, and Second functions. In addition, it can used to get the quarter of a given date (1 through 4) , the "Julian" date (the day of the year from 1 to 366), and the week number (1 through 53).

Syntax:
DatePart(interval, date[,firstdayofweek[, firstweekofyear]])

The DatePart function syntax has these parts:

Part
Description
interval
Required. String expression that is the interval of time you want to return.

The string expression can be any of the following:

Expression
Description
Possible Range of Values
"yyyy"
Year
100 to 9999
"q"
Quarter
1 to 4
"m"
Month
1 to 12
"y"
Day of year
1 to 366 (a "Julian" date)
"d"
Day
1 to 31
"w"
Weekday
1 to 7
"ww"
Week
1 to 53
"h"
Hour
0 to 23
"n"
Minute
0 to 59
"s"
Second
0 to 59
date
Required. Date value that you want to evaluate.

firstdayofweek
Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.

firstweekofyear
Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.


0 comments:

Your Ad Here