strptime

datetime

Parses a date/time string into a timestamp

Syntax

strptime(string, format)

Parameters

string (string)

The date/time string to parse

format (string)

The format pattern (e.g., "%Y-%m-%d")

Returns

timestamp

The parsed timestamp

Examples

Parse ISO date
Input:
strptime("2024-01-15", "%Y-%m-%d")
Output:
"2024-01-15"
Parse US date format
Input:
strptime("01/15/2024", "%m/%d/%Y")
Output:
"2024-01-15"
Convert string dates to timestamps
Input:
.date_string | strptime("%m/%d/%Y")
Output:
Parse date strings from data
Parse full timestamp
Input:
strptime("2024-01-15 14:30:00", "%Y-%m-%d %H:%M:%S")
Output:
"2024-01-15 14:30:00"

The strptime() function parses a date/time string according to a format pattern, converting it to a timestamp. The format uses the same codes as strftime.

Usage

Use strptime() to convert date strings to timestamps, parse dates in various formats, normalize date data, or prepare date strings for date calculations.