DateSet

See Also: Time and Date Functions

Purpose

The DateSet function returns a new DateTime value comprised of the passed year, month and day.

This can be used in place of DateSetYear, DateSetMonth and DateSetDay. It is simpler to use and it tests for a valid date.

Return Type

DateTime

Syntax

DateSet( {iYear}, {iMonth}, {iDay} )

Where:

Example

Procedure Test

    DateTime dtVar

 

    Move (DateSet(2015, 9, 26)) to dtVar

 

    // This will print (using US date settings):

    // 9/26/2015 12:00:00 AM

    Showln dtVar

End_Procedure

 

Before returning the variable the validity of the date is tested. If invalid a DFERR_INVALID_DATETIME is raised.

Example

Procedure Test

    DateTime dtVar

 

    Move (DateSet(2015, 19, 26)) to dtVar

End_Procedure

The code above will trigger error 4523 "DateTime contains an invalid value" because month 19 does not exist.

 

A null date (year=0, month=0, day=0) is considered to be an invalid date. If you wish to define a null date, use NullDateTime.

Notes