date, pure date, date time
Sorry! This is not the function where you can find your date.
This function converts date information contained in strings or numeric date information into B4P plain date type. The differences
of the three function names are described below:
date | If input variables contain date information only, then result contains the date only. If time information is provided, then the result contains both date and time information. |
date time | Result will always contain date and time. If no time information is provided, then 00:00:00 (midnight) is assumed. |
pure date | The result contains date only. Any time info will be ignored. |
Blank or missig date information will convert to blank date values. Various appraoches are available to convert value to dates:
Input Form | # Parameters required | Description |
---|---|---|
String input | 1 or 2 | Converts a string to date. Locale settings (referring to system variable 'local settings[date format short]' rule the year/month/day sequence if the date is ambiguous, e.g. "10.11.12". Change that value prior to the call if dates are ambiguous and need to use a different format assumption. See Date and Time Detection Rules for details. |
today | 1 | Uses today's date (local time zone) |
now | 1 | Uses today's date and time (local time zone) |
utc | 1 | Uses today's date and time (UTC) |
numeric date | 1 | Numeric date in YYYYMMDD format with range 19000101 ... 99993112. Values behind decimal commas are ignored, i.e. not converted to time info |
serial date | 1 | Microsoft serial date and time, as used in Excel. E.g. 44000.75 translates to 2020-06-18 18:00:00. |
numeric time | 1 | Values between 0 and 1/(24+60+60), i.e. below 1, convert to time-only information. The function pure date() returns blank date. |
date in numbers | 2 or 3 | Provide year, month and optionally day (if not specified: 1st day) to convert to date |
date and time in numbers | 4 or 5 or 6 | Like above, but also include hours, minutes and seconds. |
variable in date format | 1 | Input parameters of date types are passed through. Text representations will be elimnated. |
set | 1 | Indirect parameter passing scheme: Put the 1-6 parameters into a set, e.g. date( { 2020,12,31,23,59,59 } ); |
Vectorization: These functions support vectorization in the 1st function parameter.
Instead of providing a single value, you can provide a set or even a nested set which contain multiple values.
The function will then process every value and its return value contains a corresponding set containing all results.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
1-6
No. | Type | Description |
---|---|---|
1 input |
string | Date Convert a date (optionally with time) in a string to a date. Locale settings are used to resolve ambiguous date formats. |
Alt. 1 input |
numeral | Year See table above on 'numeric date', 'serial date' and 'numeric time' how numeric dates are converted |
Alt. 1 input |
numeral | Year Range: 1900 .. 9999. Only applicable if at least the next parameter (month) is also specified. |
Alt. 1 input |
set | Set of inputs (__Vectorization__) Provide multiple values in a (nested) paramameter set to convert to date |
Opt. 2 input |
numeral | Month Range: 1 .. 12. Only valid if 1st paramter contains a year. Default value: 1 |
Opt. 3 input |
numeral | Day Range: 1 .. 31 Default value: 1 |
Opt. 4 input |
numeral | Hour Range: 0 .. 23 Default value: Resulting date will contain no time information |
Opt. 5 input |
numeral | Minute Range: 0 .. 59 Default value: 0 |
Opt. 6 input |
numeral | Second Range: 0 .. 59 Default value: 0 |
Type | Description |
---|---|
string set |
Date and/or time Contains date, time, date and time combined or blank date. No string context of the date is preserved or included. A set containing results is returned if vectorization is applied. |
echo( date ( now ) ); // Date and time (local time zone)
echo( date ( today ) ); // Date only
echo( date ( utc ) ); // Date and time (UTC)
echo( pure date ( now ) ); // Date only (local time zone)
a[] = { 2020, 07, 14 };
echo( date ( a[] )); // Quatorze Juillet
a[] += { 22, 33, 44 }; // Add time
echo( date ( a[] )); // 2020-07-04 22:33:44
echo( date("03. Oktober 1990 21 Uhr") ); // 1990-10-03 21:00:00
2024-10-19 21:54:23
2024-10-19
2024-10-19 19:54:23
2024-10-19
{'1905-07-12 00:00:00','1900-01-07 00:00:00','1900-01-14 00:00:00'}
{'1905-07-12 00:00:00','1900-01-07 00:00:00','1900-01-14 00:00:00','1900-01-22 00:00:00','1900-02-02 00:00:00','1900-02-13 00:00:00'}
1990-10-03 21:00:00