YMD Function [Date and Time]

Returns a date value corresponding to the given year, month, and day of the month.

Syntax

YMDinteger-expression1, integer-expression2, integer-expression3 )

Parameters

Parameter

Description

integer-expression1

The year.

integer-expression2

The number of the month. If the month is outside the range 1–12, the year is adjusted accordingly.

integer-expression3

The day number. The day is allowed to be any integer, the date is adjusted accordingly.

Returns

DATE

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Example

The following statement returns the value 1998-06-12:

SELECT YMD( 1998, 06, 12 ) FROM iq_dummy

If the values are outside their normal range, the date adjusts accordingly. For example, the following statement returns the value 1993-03-01:

SELECT YMD( 1992, 15, 1 ) FROM iq_dummy

The following statement returns the value 1993-02-28:

SELECT YMD ( 1992, 15, 1-1 ) FROM iq_dummy

The following statement returns the value 1992-02-29:

SELECT YMD ( 1992, 3, 1-1 ) FROM iq_dummy