Skip to main content

module  pixeltable.functions.timestamp

Pixeltable UDFs for TimestampType. Usage example:
import pixeltable as pxt

t = pxt.get_table(...)
t.select(t.timestamp_col.year, t.timestamp_col.weekday()).collect()

udf  astimezone()

Signature
astimezone(self: pxt.Timestamp, tz: pxt.String) -> pxt.Timestamp
Convert the datetime to the given time zone. Parameters:

udf  day()

Signature
day(self: pxt.Timestamp) -> pxt.Int
Between 1 and the number of days in the given month of the given year. Equivalent to datetime.day.

udf  hour()

Signature
hour(self: pxt.Timestamp) -> pxt.Int
Between 0 and 23 inclusive. Equivalent to datetime.hour.

udf  isocalendar()

Signature
isocalendar(self: pxt.Timestamp) -> pxt.Json
Return a dictionary with three entries: 'year', 'week', and 'weekday'. Equivalent to datetime.isocalendar().

udf  isoformat()

Signature
isoformat(
    self: pxt.Timestamp,
    sep: pxt.String = 'T',
    timespec: pxt.String = 'auto'
) -> pxt.String
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
isoweekday(self: pxt.Timestamp) -> pxt.Int
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
make_timestamp(
    year: pxt.Int,
    month: pxt.Int,
    day: pxt.Int,
    hour: pxt.Int = 0,
    minute: pxt.Int = 0,
    second: pxt.Int = 0,
    microsecond: pxt.Int = 0
) -> pxt.Timestamp
Create a timestamp. Equivalent to datetime().

udf  microsecond()

Signature
microsecond(self: pxt.Timestamp) -> pxt.Int
Between 0 and 999999 inclusive. Equivalent to datetime.microsecond.

udf  minute()

Signature
minute(self: pxt.Timestamp) -> pxt.Int
Between 0 and 59 inclusive. Equivalent to datetime.minute.

udf  month()

Signature
month(self: pxt.Timestamp) -> pxt.Int
Between 1 and 12 inclusive. Equivalent to datetime.month.

udf  posix_timestamp()

Signature
posix_timestamp(self: pxt.Timestamp) -> pxt.Float
Return POSIX timestamp corresponding to the datetime instance. Equivalent to datetime.timestamp().

udf  replace()

Signature
replace(
    self: pxt.Timestamp,
    year: pxt.Int | None = None,
    month: pxt.Int | None = None,
    day: pxt.Int | None = None,
    hour: pxt.Int | None = None,
    minute: pxt.Int | None = None,
    second: pxt.Int | None = None,
    microsecond: pxt.Int | None = None
) -> pxt.Timestamp
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
second(self: pxt.Timestamp) -> pxt.Int
Between 0 and 59 inclusive. Equivalent to datetime.second.

udf  strftime()

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

udf  toordinal()

Signature
toordinal(self: pxt.Timestamp) -> pxt.Int
Return the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1. Equivalent to datetime.toordinal().

udf  weekday()

Signature
weekday(self: pxt.Timestamp) -> pxt.Int
Between 0 (Monday) and 6 (Sunday) inclusive. Equivalent to datetime.weekday().

udf  year()

Signature
year(self: pxt.Timestamp) -> pxt.Int
Between MINYEAR and MAXYEAR inclusive. Equivalent to datetime.year.