Futurebasic/Language/Reference/datestring

DATE$ functionEdit

DATE$Edit

FunctionEdit

✔ Appearance ✔ Standard ✔ Console

SyntaxEdit

dateString$ = DATE$

DescriptionEdit

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.

ExampleEdit

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

NoteEdit

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 AlsoEdit

TIME$; TIMER statement