|
G.1 Date and Time Functions
|
Explanation and example of DATE$() function
The DATE$() function returns today's date in various formats.
print date$ // Default format: YYYYMMDD
print date$(days(date$), 1) // Format: MMDDYYYY
print date$(days(date$), 2) // Format: DDMMYYYY
print date$(days(date$), 3) // Format: dd-Mon-yyyy
print date$(days(date$), 4) // Format: Month dd, yyyy
Explanation and example of DAYS() function
The DAYS() function returns the Julian day number for a given date.
print days('20000122') // Returns: 146119
print days('990122') // Returns: 145754
print days('20000103', 0) // Returns: 146100
print days('01032000', 1) // Returns: 146100
print days('03012000', 2) // Returns: 146100
print days('03-Jan-2000', 3)// Returns: 146100
print days('January 3, 2000', 4) // Returns: 146100
Explanation and example of DAY$() function
The DAY$() function returns the day of the week for a given number of days since January 1, 1600, or for today if no integer is specified.
print day$ // Returns today's day of the week
print day$(12345) // Returns the day of the week for 12345 days since January 1, 1600
Explanation and example of FULLTIME$() function
The FULLTIME$() function returns the date and time in various
formats based on the number of seconds since January 1, 1600.
print fulltime$ // Returns current date and time
sec = seconds('20000121 115042')
print fulltime$(sec, 0) // Format: CCYYMMDD HHMMSS
print fulltime$(sec, 1) // Format: MMDDCCYY HHMMSS
print fulltime$(sec, 2) // Format: DDMMCCYY HHMMSS
print fulltime$(sec, 3) // Format: DD-Mon-CCYY HH:MM:SS
print fulltime$(sec, 4) // Format: Month DD, CCYY HH:MM:SS
Explanation and example of SECONDS() function
The SECONDS() function converts a full-time string to the
number of seconds since January 1, 1600.
z = seconds('20000122 103050') // Returns: 12624633050
z1 = seconds('990122 103050') // Returns: 12593097050
z2 = seconds('103050') // Returns: 37850 (seconds since midnight)
z3 = seconds('1030') // Returns: 37800 (seconds since midnight)
Explanation and example of TIME() function
The TIME() function returns various time values based on the input integer.
print time(0) // Returns: Seconds since midnight
print time(1) // Returns: CPU time of the process
print time(2) // Returns: Connect time of the process
print time(5) // Returns: Seconds since sheerpower was invoked
Explanation and example of TIME$() function
The TIME$() function returns the current time in HH:MM:SS format, or
the time based on the number of seconds since midnight if specified.
print time$ // Returns current time of day
print time$(1800) // Returns: 00:30
print time$(54178) // Returns: 15:02
sheerpower has many more ways to work with date and time-related operations. See
here
for more details.