time, pure time

Prev Next

Function Names

time, pure time

Description

This function converts time information contained in strings or numeric date information into B4P plain date type. The differences of the two function names are described below:

time Dates without time info convert to blank dates. Dates with time info are converted as expected.
pure time Result will always contain a time. Blank dates and date-only information convert to 00:00:00 (midnight).



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 Meaningless, because it contains no time info.
now 1 Uses today's time (local time, today's date is ignored)
utc 1 Uses today's date and time (UTC)
numeric date 1 Meaningless, because it contains no time info
serial date 1 Microsoft serial date and time, as used in Excel. Only the fraction is used E.g. 44000.75 translates to 18:00:00.
numeric time 1 Values between 0 and 1/(24+60+60), i.e. below 1, convert to time-only information
time in numbers 1 or 2 or 3 Provide hour, minute and optonally second to convert to time
date and time in numbers 4 or 5 or 6 Like above, but also include hours, minutes and seconds
variable in date format 1 Time info of the date will be passed through. Text representations will be elimnated.
set 1 Indirect parameter passing scheme: Put the 1-6 parameters into a set, e.g. date( { 23,59,59 } );



Vectorization: The function names beginning with the prefix v 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.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1-3

Parameters

No.TypeDescription
1
input
string Time

Convert a time in a string to a date variable containing time information only. The keyword 'now' returns the current time of day.
See Date and Time Detection Rules for ruling details.

Alt. 1
input
numeral Hour

Range: 0 .. 23

Alt. 1
input
set Set of inputs (__Vectorization__)

Provide multiple values in a (nested) paramameter set to convert to time

Opt. 2
input
numeral Minute

Range: 0 .. 59

Default value: 0
Opt. 3
input
numeral Second

Range: 0 .. 59

Default value: 0

Return value

TypeDescription
string
set
Date and/or time

Contains time or blank date. No string context of the date is preserved or included. A set containing results is returned if vectorization is applied.

Examples

               echo( time ( now ) );
               echo( pure time ( today ) );   // 00:00:00
               echo( time ( "08:30 p.m." ));  // 20:30:00
               a[] = { 20, 15, 30 };
               echo( time ( a[] ));           // 20:15:30
               echo( time ( '2020-12-31' ) ); // Blank date value
               echo( time ( 19/24 ));         // 19:00:00

Output

21:57:23
00:00:00
20:30:00
{'20:00:00','15:00:00','30:00:00'}

19:00:00
Try it yourself: Open LIB_Function_time.b4p in B4P_Examples.zip. Decompress before use.

See also

date conversion functions
date
pure date
date time