Date and Time Operations

These operations will allow you to work with date and time data in Kognitos.

1. Getting Current Date and Time Information

1.1. Get the Current Date

Returns the current date in MM/DD/YYYY format, such as 01/01/2024.

get the current date

1.2. Get the Current Time

Returns the current time in the format HH:MM:SS AM/PM, such as 02:30:45 PM.

get the current time

1.3. Get the Current Year

Returns the current year in the format YYYY, such as 2024.

get the current year

1.4. Get the Current Month

Returns the current month by name, such as February.

get the current month

1.5. Get the Current Day

Returns the current day by name, such as Thursday.

get the current day

1.6. Get the Current Hour

Returns the current hour in 12-hour format along with AM/PM. For example: 02PM.

get the current hour

2. Converting Date Strings into Dates

This operations converts date strings (text representations of dates) into date objects.

Syntax

the strings are {string}, {string}, {string}
the department's timezone is {timezone}
if the strings is not empty then
    filter the strings into the dates

Inputs

  1. string
    • A text representation of a date.
    • Example: 2024-04-01, April 2nd, 2023
  2. timezone
    • The timezone of the department.
    • Example: EST, UTC

Example

the strings are "2024-10-01", "not a date", "October 22nd, 2024"
the department's timezone is "EST"
if the strings is not empty then
    filter the strings into the dates

πŸ“– Results:

  • 2024-10-01
  • 2024-01-01

3. Sorting Dates

This operation sorts a list of dates in ascending order.

Syntax

the dates are "{date}", "{date}", "{date}"
sort the dates

Example

the dates are "2024-01-01", "2022-12-31", "2023-01-02"
sort the dates

πŸ“– Results

  • 2022-12-31
  • 2023-01-02
  • 2024-01-01

4. Converting Text To Date

This operations converts text into a date in YYYY-MM-DD format.

Syntax

convert "{text}" to a date

Example

convert "October 23, 2024" to a date

πŸ“– Results

  • 2024-10-23

5. Converting Date Strings to Different Formats

This operation converts text to a date in a specific format.

For example, say you have a text representation of a date, such as 2024-10-23 00:00:00, and you want to convert it to a different format, such as 10/23/24.

This is done by converting the text into a datetime object and then converting it back into text into the desired format.

Syntax

convert "{text date}" to a datetime
convert the above to a text where
  the format is "{format}"

Inputs

  1. text date: The text representation of a date to be converted.
  2. format: The format to convert the date into.

Example

convert "2024-10-23" to a datetime
convert the above to a text where
  the format is "%m/%d/%y"

πŸ“– Results

  • 10/23/24