NTD
SQL Number to String Date
This string function returns the formatted string value of an SQL numeric format date.
Syntax
Section titled “Syntax”NTD (numeric-value [,date-mask] [,ERR=line-ref|,ERC=error-code])numeric-value- is any number in the range -3652135.00000 to 3652061.99999 representing the SQL numeric format values for 01-JAN-9999BC 00:00:00 and 31-DEC-9999AD 23:59:59. A value of zero (0) returns the current date and time.
date-mask- is any string containing a date format using the characters specified below. The default date-mask is "DD-MON-YYYY HH:MI:SS".
line-ref- is the program line number or label to branch to if an error is produced by this function.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”This function is generally available starting with release level 8.0.
The range of valid dates is 01-JAN- B9999 (9999BC) through 31-DEC-9999 (9999AD).
If numeric value is outside the range given above, an ERR=41 results.
The first date in AD is 01-JAN-0001, which is 1 in SQL numeric format. There was no year 0000, so the day just prior to 01-JAN-0001 is 31-DEC- B0001, which is B1 in SQL numeric format.
SQL numeric format represents days and decimal days. 1.5 is the proper number for 01-JAN-0001 12:00:00, 1.75 yields 01-JAN-0001 18:00:00, B0.25 is 31-DEC- B0001 18:00:00, and B0.75 is 31-DEC- B0001 06:00:00.
The following list of masking characters are valid as shown:
YY- Two-digit year, showing only the least significant two digits of the year.
YYY- Three-digit year, showing only the least significant three digits of the year.
YYYY- Full four-digit year; leading minus sign appears for BC dates.
MM- Two-digit month (e.g. January = 01, December = 12).
MON- Uppercase, three-character abbreviation of the month (e.g. "JAN").
MONTH- Full uppercase name of the month (e.g. "JANUARY").
Mon- Upper/lowercase, three-character abbreviation of the month (e.g. "Jan").
Month- Upper/lowercase, full name of the month (e.g. "January").
DD- Two-digit day of the month.
DDD- Three-digit day of the year (Julian) from 1 through 366. This mask is generally available starting with release level 8.1.
DY- Uppercase three-character abbreviation of the day of the week (e.g. "MON").
DAY- Uppercase full day of the week (e.g. "MONDAY").
Dy- Upper/lowercase three character abbreviation of the day of the week (e.g. "Mon").
Day- Upper/lowercase full day of the week (e.g. "Monday").
HH- Hour of the day in 24-hour format.
MI- Minutes.
SS- Seconds.
SS.SSSSSS- Seconds of time given in maximum of 6-decimal place accuracy.
AM or PM- Returns "AM" for clock times between midnight and noon; "PM" for clock times between noon and midnight.
Examples
Section titled “Examples”Assuming that MASK$ = “Day, Month DD, YYYY at HH:MI:SS”
NTD (1, MASK$)returns “Saturday, January 01, 0001 at 00:00:00”.
NTD (359,MASK$)returns “Sunday, December 25, 0001 at 00:00:00”.
NTD (726463, MASK$)returns “Monday, December 25, 1989 at 00:00:00”.
NTD (726574.4, MASK$)returns “Sunday, April 15, 1990 at 09:36:00”.
See also
Section titled “See also”DTN function CDN, CDS, and DATESTRINGS system variables SET DATESTRINGS directive
From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF