Date Functions

Return to the Index
DATE | DATEDIF | DATEVALUE | DAY | HOUR | MINUTE | MONTH | NOW | SECOND | TIME | TIMEVALUE | TODAY | WEEKDAY | WEEKNUM | YEAR

DATE
Returns a date specified by the given arguments.

Syntax:

DATE(year, month, day)

year is number representing the year. If < 1900 then 1900 is added to the number.
month is number from 1 to 12 representing the month.
day is number from 1 to 31 representing the day.

Example:

date(2003, 11, 2) equals Nov. 2, 2003

DATEDIF
Returns the number of time intervals between two dates. Note: positive value returned when date2 > date1.
    Interval  Description
    --------  -----------
    y         Returns the number of years.
    m         Returns the number of months.
    d         Returns the number of days.
    ym        Returns the number of months (day and year ignored).
    yd        Returns the number of days (year ignored).
    md        Returns the number of days (month and year ignored).

Syntax:

DATEDIF(date1, date2, interval)

date1 and date2 is any date.
interval is any intervals listed above.

Example:

datedif("3/1/00", "8/2/03", "yd") equals 154

DATEVALUE
Converts a string to a date.

Syntax:

DATEVALUE(date_text)

date_text is a string that represents a date.

Example:

month(datevalue("3/1/00")

DAY
Returns the day given a date.

Syntax:

DAY(date)

date is any date.

Example:

day(date(2003, 11, 2)) equals 2

HOUR
Returns the hour given a date.

Syntax:

HOUR(date)

date is any date.

Example:

hour(timevalue("3:37 PM")) equals 15

MONTH
Returns the month given a date.

Syntax:

MONTH(date)

date is any date.

Example:

month(now()) equals 9

NOW
Returns the current date and time.

Syntax:

NOW()

TIME
Returns a date specified by the given arguments with just the time values set.

Syntax:

TIME(hour, minute, second)

hour is a number from 0 to 23.
minute is a number from 0 to 59.
second is a number from 0 to 59.

Example:

time(4, 5, 6) equals 6

TIMEVALUE
Converts a string to a date with just the time values set.

Syntax:

TIMEVALUE(time_text)

time_text is a string that represents a time.

Syntax:

Example:

timevalue("3:37 PM")

TODAY
Returns the current date.

Syntax:

TODAY()

YEAR
Returns the year given a date.

Syntax:

YEAR(date)

date is any date.

Example:

year(datevalue("3/1/00")) equals 2000

SECOND
Returns the second given a date.

Syntax:

SECOND(date)

date is any date.

Example:

second(time(4, 5, 6)) equals 6

WEEKDAY
Returns the weekday given a date.

Syntax:

WEEKDAY(date,return_type)

date is any date.
return_type is 1 or omitted returns 1 (Sunday) to 7 (Saturday). If 2 then returns 1 (Monday) to 7 (Sunday). If 3 then returns 0 (Monday) to 6 (Sunday).

Example:

weekday(date(2003, 11, 2)) equals 1

WEEKNUM
Returns the weeknum given a date.

Syntax:

WEEKNUM(date,firstDay)

date is any date.
firstDay is 1 or omitted means Sunday is the first day. If 2 then Monday is used as the first day.

Example:

WEEKNUM(3) equals 2

Copyright 2003-2005 Diamond Edge, Inc. All rights reserved.