Date

DIM Var AS Date

This native datatype represents a date & time value.

Dates are stored internally as a couple of integer numbers:
  • The first is the number of days since the origin, a specific instant in the past.

  • The last is the number of milliseconds added to that number of days.

Dates can be converted to numbers. Then the number returned is the number of days stored internally and the fraction of day represented by the number of microseconds.

If you extend the Gregorian calendar to the past (beware that there is no zero year), the smallest date is January 1st, 4801 BC. See Dates and calendars for more details.

To specify a date, you usually use a string representation of that date. Some Gambas functions read or write only the american format in UTC time (CDate, CStr), and others understand the local date representation in local time (Val, Str$, PRINT).

Seit 3.18

Since Gambas 3.18, the timezone can be explicitly specified in a date string representation.

The syntax is:

<Old date string representation> <space> [ UTC | GMT ] [ + | - ] HH [ :MM ]

Example

Print Now;; "|";; CFloat(Now)
07/13/2005 02:20:08 | 2485669.138981

Print CDate("11/17/2022 16:33 UTC+2")
11/17/2022 15:33:00

See also