DatePart()

Top  Previous  Next

DatePart() - Determine Specified Part of a Given Date

Description

The DatePart() function is used to determine the specified part of a given date, for example the day of the week or the month of the year.

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

Parameters
The interval parameter is a string expression representing the the interval type to return. See the table below for possible values:

Value

Description

d

Day

m

Month

yyyy

Year

w

Weekday

y

Day of year

ww

Week of year

q

Quarter

h

Hour

n

Minute

s

Second

The date parameter specifies the date to evaluate.

The optional parameter firstdayofweek specifies the [id=44#days]day of the week[/id] to use as the first day. If not specified, Sunday is the default value.

The optional firstweekofyear parameter specific the how the [id=44#weeks]first week of the year[/id] is defined.

Examples
Determine the current day of the week.

SMEvent.Raise "Trace", DatePart("w", now)

Determine the quarter which April 1st, 1964 fell in.

SMEvent.Raise "Trace", DatePart("q", "1-Apr-64")