Datetime Type

**Overview**

  • Stores date and time as the number of seconds elapsed since January 01, 1970.
  • Occupies 8 bytes of memory.
  • Range: January 1, 1970, to December 31, 3000.
  • **Literals**

  • Represented as a literal string enclosed in single quotes, starting with 'D'.
  • Format: D'YYYY.MM.DD HH:MM:SS' or D'DD.MM.YYYY HH:MM:SS'.
  • Components: Year, Month, Day, Hours, Minutes, Seconds.
  • Partial specification is allowed (e.g., D'19.07.1980 12', D'01.01.2004').
  • Omitting date or time components results in default values (00:00:00 for time, or current compilation date for date if only time is specified).
  • Compiler returns a warning for incomplete date entries.
  • **Special Literals**

  • __DATE__: Compilation date.
  • __DATETIME__: Compilation date and time.
  • **String Conversion**

  • Without #property strict: Converts to the number of seconds (e.g., 1394034418).
  • With #property strict: Converts to the literal string format (e.g., 2014.03.05 15:46:58).
  • **Related Topics**

  • [Structure of the Date Type](/constants/structures/mqldatetime)
  • [Date and Time](/dateandtime)
  • [TimeToString](/convert/timetostring)
  • [StringToTime](/convert/stringtotime)