DatePart Function

DatePart āĻĢāĻžāĻ‚āĻļāĻ¨āĻŸāĻŋ āĻāĻ•āĻŸāĻŋ āĻ¤āĻžāĻ°āĻŋāĻ–ā§‡āĻ° āĻ‰āĻ˛ā§āĻ˛ā§‡āĻ–āĻŋāĻ¤ āĻ…āĻ‚āĻļ āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ•āĻ°ā§‡ āĻĨāĻžāĻ•ā§‡āĨ¤

Syntax:


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

āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻŽāĻžāĻ¨:

The extracted part for the given date.

Parameters:

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

interval (string value)

āĻŦā§āĻ¯āĻžāĻ–ā§āĻ¯āĻž

yyyy

āĻŦāĻ›āĻ°

q

āĻšāĻ¤ā§āĻ°ā§āĻĨāĻžāĻ‚āĻļ

m

āĻŽāĻžāĻ¸

y

āĻŦāĻ›āĻ°ā§‡āĻ° āĻĻāĻŋāĻ¨

w

āĻ•āĻ°ā§āĻŽāĻĻāĻŋāĻŦāĻ¸

ww

āĻŦāĻ›āĻ°ā§‡āĻ° āĻ¸āĻĒā§āĻ¤āĻžāĻš

d

āĻĻāĻŋāĻ¨

h

āĻ˜āĻ¨ā§āĻŸāĻž

n

āĻŽāĻŋāĻ¨āĻŋāĻŸ

s

āĻ¸ā§‡āĻ•ā§‡āĻ¨ā§āĻĄ


date - The date from which the result is calculated.

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

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

firstdayofweek value

āĻŦā§āĻ¯āĻžāĻ–ā§āĻ¯āĻž

0

āĻ¸āĻŋāĻ¸ā§āĻŸā§‡āĻŽā§‡āĻ° āĻĄāĻŋāĻĢāĻ˛ā§āĻŸ āĻŽāĻžāĻ¨ āĻŦā§āĻ¯āĻŦāĻšā§ƒāĻ¤ āĻšā§Ÿ

1

āĻ°āĻŦāĻŋāĻŦāĻžāĻ° (āĻĄāĻŋāĻĢāĻ˛ā§āĻŸ)

2

āĻ¸ā§‹āĻŽāĻŦāĻžāĻ°

3

āĻŽāĻ™ā§āĻ—āĻ˛āĻŦāĻžāĻ°

4

āĻŦā§āĻ§āĻŦāĻžāĻ°

5

āĻŦā§ƒāĻšāĻ¸ā§āĻĒāĻ¤āĻŋāĻŦāĻžāĻ°

6

āĻļā§āĻ•ā§āĻ°āĻŦāĻžāĻ°

7

āĻļāĻ¨āĻŋāĻŦāĻžāĻ°


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

firstweekofyear value

āĻŦā§āĻ¯āĻžāĻ–ā§āĻ¯āĻž

0

āĻ¸āĻŋāĻ¸ā§āĻŸā§‡āĻŽā§‡āĻ° āĻĄāĻŋāĻĢāĻ˛ā§āĻŸ āĻŽāĻžāĻ¨ āĻŦā§āĻ¯āĻŦāĻšā§ƒāĻ¤ āĻšā§Ÿ

1

āĻŦāĻ›āĻ°ā§‡āĻ° ā§§āĻŽ āĻ¸āĻĒā§āĻ¤āĻžāĻšāĻŸāĻŋ āĻšāĻ˛ā§‹ ā§§āĻ˛āĻž āĻœāĻžāĻ¨ā§ā§ŸāĻžāĻ°āĻŋ āĻ¸āĻŽā§āĻŦāĻ˛āĻŋāĻ¤ āĻ¸āĻĒā§āĻ¤āĻžāĻš (āĻĄāĻŋāĻĢāĻ˛ā§āĻŸ)

2

āĻ¸āĻĒā§āĻ¤āĻžāĻš ā§§ āĻšāĻ˛ā§‹ āĻ¸ā§‡āĻ‡ āĻŦāĻ›āĻ°ā§‡āĻ° āĻšāĻžāĻ° āĻ…āĻĨāĻŦāĻž āĻ¤āĻ¤ā§‹āĻ§āĻŋāĻ• āĻĻāĻŋāĻ¨ āĻŦāĻŋāĻļāĻŋāĻˇā§āĻŸ āĻĒā§āĻ°āĻĨāĻŽ āĻ¸āĻĒā§āĻ¤āĻžāĻš

3

āĻ¸āĻĒā§āĻ¤āĻžāĻš ā§§ āĻšāĻ˛ā§‹ āĻ¨āĻ¤ā§āĻ¨ āĻŦāĻ›āĻ°ā§‡āĻ° āĻļā§āĻ§ā§āĻŽāĻžāĻ¤ā§āĻ° āĻĻāĻŋāĻ¨ āĻŦāĻŋāĻļāĻŋāĻˇā§āĻŸ āĻĒā§āĻ°āĻĨāĻŽ āĻ¸āĻĒā§āĻ¤āĻžāĻš


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!