Skip to main content

module  pixeltable.functions.timestamp

Pixeltable UDFs for TimestampType. Usage example:

udf  add_seconds()

Signature
Add seconds to the timestamp. The offset is elapsed time: 86400 seconds across a daylight saving time change move the wall-clock time by 23 or 25 hours. A timestamp without a time zone is in the default time zone. t.ts + timedelta(...) and t.ts - timedelta(...) are shorthand for add_seconds(). seconds_since() returns the offset between two timestamps. Parameters:
  • seconds (pxt.Float): The number of seconds to add. A negative number subtracts.
Examples: The time one hour after created_at:
The tickets created during the last 7 days:

udf  astimezone()

Signature
Convert the datetime to the given time zone. Parameters:

udf  day()

Signature
Between 1 and the number of days in the given month of the given year. Equivalent to datetime.day.

udf  hour()

Signature
Between 0 and 23 inclusive. Equivalent to datetime.hour.

udf  isocalendar()

Signature
Return a dictionary with three entries: 'year', 'week', and 'weekday'. Equivalent to datetime.isocalendar().

udf  isoformat()

Signature
Return a string representing the date and time in ISO 8601 format. Equivalent to datetime.isoformat(). Parameters:
  • sep (pxt.String): Separator between date and time.
  • timespec (pxt.String): The number of additional terms in the output. See the datetime.isoformat() documentation for more details.

udf  isoweekday()

Signature
Return the day of the week as an integer, where Monday is 1 and Sunday is 7. Equivalent to datetime.isoweekday().

udf  make_timestamp()

Signature
Create a timestamp. Equivalent to datetime().

udf  microsecond()

Signature
Between 0 and 999999 inclusive. Equivalent to datetime.microsecond.

udf  minute()

Signature
Between 0 and 59 inclusive. Equivalent to datetime.minute.

udf  month()

Signature
Between 1 and 12 inclusive. Equivalent to datetime.month.

udf  now()

Signature
Return the current time in the default time zone. A query, or a computed column with stored=False, evaluates it when the query runs. A stored computed column records the time of the insert, and a recompute replaces it with the time of the recompute. Equivalent to datetime.now(), with the default time zone as tz. Examples: The tickets that are past due:
A column that stays current, in a table model:

udf  posix_timestamp()

Signature
Return POSIX timestamp corresponding to the datetime instance. Equivalent to datetime.timestamp().

udf  replace()

Signature
Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified. Equivalent to datetime.replace().

udf  second()

Signature
Between 0 and 59 inclusive. Equivalent to datetime.second.

udf  seconds_since()

Signature
Return the number of seconds from start to the timestamp. The result is elapsed time, and it is negative if the timestamp is earlier than start. A timestamp without a time zone is in the default time zone. add_seconds() adds such an offset to a timestamp. Parameters:
  • start (pxt.Timestamp): The start of the measured interval.
Examples: The time each ticket took to resolve, in hours:

udf  strftime()

Signature
Return a string representing the date and time, controlled by an explicit format string. Equivalent to datetime.strftime(). Parameters:

udf  strip_timezone()

Signature
Return a naive datetime with the same wall-clock as self and no tzinfo. Equivalent to datetime.replace(tzinfo=None).

udf  strptime()

Signature
Parse a timestamp from date_string according to format. A timestamp without a time zone is in the default time zone. Equivalent to datetime.strptime(). For an ISO 8601 string, astype(pxt.Timestamp) is enough. Parameters:
  • date_string (pxt.String): The string to parse.
  • format (pxt.String): The format of date_string. For a complete list of formatting directives, see strftime() and strptime() Behavior.
Examples:

udf  toordinal()

Signature
Return the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1. Equivalent to datetime.toordinal().

udf  weekday()

Signature
Between 0 (Monday) and 6 (Sunday) inclusive. Equivalent to datetime.weekday().

udf  year()

Signature
Between MINYEAR and MAXYEAR inclusive. Equivalent to datetime.year.
Last modified on December 4, 2026