Date Constants

Official Content
This documentation is valid for:

You can use date and date-time constants with ANSI/ISO (AAAA-MM-DD HH:MM:SS) format in any GeneXus expression (rules, conditions, procedures, formulas, etc).


<date>::=    [0-9]{1,4}"/"[0-9]{1,2}"/"[0-9]{1,2} | [0-9]{1,4}"."[0-9]{1,2}"."[0-9]{1,2} | [0-9]{1,4}"-"[0-9]{1,2}"-"[0-9]{1,2}

<hms>::=    [0-9]{1,2}[ap] | [0-9]{1,2}":"[0-9]{1,2}[ap]? | [0-9]{1,2}":"[0-9]{1,2}":"[0-9]{1,2}[ap]?

<constant> ::=   "#"<date>"#" | "#"<date> <hms>"#" | "#"<hms>"#"


This kind of constants can be used in rules, events and properties, and in any code edition that involves the parser as well.



&InitialDateTime=#07-1-1 11:15a#


Constants provide a simpler way to initialize variables/attributes, or an alternative to using character-conversion functions like CTOD or TTOC where needed, as in previous versions.


  • When the constant does not include the century (07-01-01), the "First Year of 20th Century" property is applied.
  • To initialize the date or date-time attribute/variable with an "empty value", it is recommended to use the "nullvalue" function or "setempty" method (i.e.: &InitialDate=NullValue(&InitialDate)) instead of assigning a constant like #0001-01-01#. The reason for this is that #0001-01-01# is not a supported value for all DBMSs. For example, MS SQL Server does not support this value; the lowest date value supported is  #1753-01-01# (See Attribute Empty Value for each DBMS and Data Type for more details).
  • The time part of a datetime may be expressed using 12-hour or 24-hour formats; the value range of these formats can be viewed at