DATE

DATE operator converts its non-DATE operand to the DATE data type.

This non-DATE operand can be a DATETIME, character, or integer expression:

Description: DATE%20Operator

DATE operator is sensitive to the time when the application was executed and to the accuracy of your system clock. 

If you supply no operand to the DATE operator, it will read the system clock and return the current date as a character string.

The returned value will have this format:

weekday month day year

where weekday and month are three-character abbreviations for the day and month.

 

For example, this example program

MAIN

DEFINE my_date CHAR(15)

DEFINE tmp STRING

LET my_date = DATE

LET tmp = "This program was executed on ", my_date

CALL fgl_winmessage("DATE operator", tmp, "info")

CALL fgl_getkey()

END MAIN

will display this message on Monday, the 1st of January, 2001:

DATE operator can be also used to

Other ways to format DATE values as a character string are

This example program shows how the DATE operator can be used:

MAIN

DEFINE my_date DATE,

       my_date_time DATETIME YEAR TO DAY

 

LET my_date = DATE (" 02/09/04 ") -- this line requires the default DATE format

DISPLAY "DATE (\" 02/09/04 \") Result: ", my_date at 5,5

 

LET my_date = DATE (" 2004-02-09 ") -- it requires DBDATE to be set to Y4MD-

DISPLAY "DATE (\" 2004-02-09 \") Result: ", my_date at 6,5

 

LET my_date = DATE (" 09:04:02 ") -- this line requires that DBDATE be set to DY2M:

DISPLAY "DATE (\" 09:04:02 \") Result: ", my_date at 7,5

 

LET my_date = DATE(my_date) -- The operand can be a DATE variable, as illustrated,

DISPLAY "DATE(my_date) Result: ", my_date at 8,5

 

-- or getting the integer number of days since the last day of the year 1899

LET my_date = DATE (0) -- The result is: 12/31/1899

DISPLAY "DATE (0) Result: ", my_date at 9,5

 

LET my_date = DATE (38000) -- The result is: 15/1/2004

DISPLAY "DATE (38000) Result: ", my_date at 10,5

 

-- Or the operand can also be of data type DATETIME

LET my_date_time = CURRENT

DISPLAY "CURRENT Result: ", my_date_time at 11,5

 

LET my_date = DATE (my_date_time) -- the result is today's date

DISPLAY "DATE (my_date_time) Result: ", my_date_time at 12,5

 

LET my_date = DATE(CURRENT) -- the same result as previous

DISPLAY "DATE(CURRENT) Result: ", my_date_time at 13,5

 

CALL fgl_getkey()

END MAIN

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.