Futurebasic/Language/Reference/datestring

DATE$ function

edit

DATE$

edit

Function

edit

✔ Appearance ✔ Standard ✔ Console

Syntax

edit

dateString$ = DATE$

Description

edit

The DATE$ function reads the system clock and returns the current date as a string in the format: MM/DD/YY (that is, the string returned contains two digit numerals each for month, day and year, separated by slash marks).

You can use the Toolbox routine IUDATESTRING to get a date string that is formatted according to the international specifications set in the "Date & Time" control panel. See the sample program IUDATESTRING.BAS to see how this is done.

Example

edit

res/cd.gif image CD Example: IUDATESTRING.BAS

Note

edit

The DATE$ function only returns the last two digits of the year. To get the complete 4-digit year value, you can use the SECONDSTODATE Toolbox function (previously SECS2DATE - both are supported in FutureBasic), as follows:

DIM dateRec AS DateTimeRec
DIM secs&
DIM theMonth%,theDay%,theYear%,theWeekday%
CALL GETDATETIME( secs& )
CALL SECONDSTODATE(secs&,dateRec)
theMonth%  = dateRec.month
theDay%    = dateRec.day
theYear%   = dateRec.year       'Full 4 digits
theWeekday% = dateRec.dayOfWeek '1=Sunday, 7=Saturday
PRINT theMonth%
PRINT theDay%
PRINT theYear%
PRINT theWeekday%

See Also

edit

TIME$; TIMER statement