FromStringToDate

STD.Date.FromStringToDate( date_text, format )

date_textThe string to be converted
formatThe format of the input string. See strftime documentation for details (http://strftime.org/)
returnThe date that was matched in the string. Returns 0 if failed to match or if the date components match but the result is an invalid date.

The FromStringToDate function converts a string to a Date_t using the relevant string format.

If the resulting date must be representable within the Gregorian calendar after the year 1600, you should use the Std.Date.IsValidGregorianDate() function to determine its validity.

Supported characters:

    %B          Full month name
    %b or %h    Abbreviated month name
    %d          Day of month (two digits)
    %e          Day of month (two digits, or a space followed by a single digit)
    %m          Month (two digits)
    %t          Whitespace
    %y          year within century (00-99)
    %Y          Full year (yyyy)
    %j          Julian day (1-366)

Common date formats

    American    '%m/%d/%Y'  mm/dd/yyyy
    Euro        '%d/%m/%Y'  dd/mm/yyyy
    Iso format  '%Y-%m-%d'  yyyy-mm-dd
    Iso basic   '%Y%m%d'     yyyymmdd
                '%d-%b-%Y'  dd-mon-yyyy    e.g., '21-Mar-1954'

Example:

IMPORT STD;
 
D1 := STD.Date.FromStringToDate('19720607', '%Y%m%d');
    //D1 contains 19720607
D2 := STD.Date.FromStringToDate('19720007', '%Y%m%d');
    //D2 contains 0
D3 := STD.Date.FromStringToDate('4/29/1974', '%m/%d/%Y');
    //D3 contains 19740429
D4:= STD.Date.FromStringToDate('29/4/1974', '%d/%m/%Y');
    //D4 contains 19740429
 

See Also: IsValidGregorianDate