find dates

Prev Next

Function Names

find dates

Description

Do no think about next Friday night attending this function and then calling for 'sleep until()'! Let's keep our head and hands in front of our computer, at least for now.

This function checks the input parameter, which can be a single value or a set containing values, for dates and retuns them in a set containing all identified dates. Dates identified in string will be converted to dates. In order to avoid regional ambiguities, only strict date and/or time formats are allowed:

  • YYYY-MM-DD
  • hh:mm:ss
  • YYYY-MM-DD hh:mm:ss

All other values, including blank dates, will be discarded. The key benefit here is to gather all dates in tables across one or multiple columns keeping all blank and garbage contents outside.

Call as: function

Parameter count

1-2

Parameters

No.TypeDescription
1
input
all types Target date / time

This parameter will be searched for date and time values. It may contain single values, sets and nested sets of any depth. All elements will be checked for dates and time info.

2
input
string Option

Following options are supported:

  • any: Look for any date or time values
  • date: Look for dates, but ignore all values containing time info
  • time: Look for time info, but ignore all values containing dates
  • date time: Look for values containing both date and time info
  • contains date: Look for values containing date or both date and time info
  • contains time: Look for values containing time or both date and time info

Default value: any

Examples


       a[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, all );
       b[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, date );
       c[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, time );
       d[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, date time );
       e[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, contains date );
       f[]= find dates( { "2025-08-01", date(''), Coffee time, date(today), time("10:15:30"), date("2025-03-03 12:01:02") }, contains time );

       echo("any:           ", a[]);
       echo("date:          ", b[]);
       echo("time:          ", c[]);
       echo("date time:     ", d[]);
       echo("contains date: ", e[]);
       echo("contains time: ", f[]);

Output

any:           {'2025-08-01','2025-09-21','10:15:30','2025-03-03 12:01:02'}
date:          {'2025-08-01','2025-09-21'}
time:          {'10:15:30'}
date time:     {'2025-03-03 12:01:02'}
contains date: {'2025-08-01','2025-09-21','2025-03-03 12:01:02'}
contains time: {'10:15:30','2025-03-03 12:01:02'}
Try it yourself: Open LIB_Function_find_dates.b4p in B4P_Examples.zip. Decompress before use.

See also

date