pA2jY‖DatePart Function

Contents
2gQJj‖

# FZMy8‖DatePart Function

i4c5k‖The DatePart function returns a specified part of a date.

### FVEx2‖Syntax:

    GWMCJ‖DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long

### wi5B9‖Return value:

V53FC‖The extracted part for the given date.

### WADQ4‖Parameters:

4Dk4X‖ interval - A string expression from the following table, specifying the date interval.

yKYH5‖interval (string value) | BrkDy‖Explanation
--- | ---
yyyy | uCMGD‖Year
q | aAbFF‖Quarter
m | DnwYQ‖Month
y | 5ceAL‖Day of year
w | zMz7B‖Weekday
ww | Wknbt‖Week of year
d | QUMAr‖Day
h | bW8VY‖Hour
n | E7sMZ‖Minute
s | saACB‖Second

KDtSw‖ date - The date from which the result is calculated.

5FGDA‖Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:

- #yyyy-mm-dd#

- #mm/dd/yyyy#

hjbSu‖ firstdayofweek: An optional parameter that specifies the starting day of a week.

wpCoP‖firstdayofweek value | gmaR8‖Explanation
--- | ---
A5RkW‖0 | Xt9Xx‖Use system default value
6UMdD‖1 | uV8iz‖Sunday (default)
zuFMX‖2 | vUz3C‖Monday
2YAp3‖3 | KCW5A‖Tuesday
8rkEA‖4 | hhEsB‖Wednesday
3F47C‖5 | Zv7Dn‖Thursday
aP5Bd‖6 | EbThD‖Friday
CmnqZ‖7 | BjBfG‖Saturday

UFDDA‖ firstweekofyear: An optional parameter that specifies the starting week of a year.

e3gQd‖firstweekofyear value | zAFFS‖Explanation
--- | ---
XEzpc‖0 | jXczC‖Use system default value
sqUf8‖1 | 65vhA‖Week 1 is the week with January, 1st (default)
7KXnC‖2 | wFZe8‖Week 1 is the first week containing four or more days of that year
85UKo‖3 | xAkGk‖Week 1 is the first week containing only days of the new year

### EFSA4‖Example:

    Sub example_datepart
        MsgBox DatePart("ww", #01/02/2005#) ' displays 2 because weeks start on Sunday
        MsgBox DatePart("ww", #12/31/2005#) ' displays 53
        MsgBox DatePart(date:=#2005-12-30#, interval:="q") ' displays 4
    End Sub

Please support us!