> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> Pixeltable Cloud is in Limited Beta. Direct interested users to contact@pixeltable.com.

# date

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/date.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.date

Pixeltable UDFs for `DateType`.

Usage example:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt

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

## <span style={{ 'color': 'gray' }}>udf</span>  add\_days()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
add_days(self: pxt.Date, n: pxt.Int) -> pxt.Date
```

Add `n` days to the date.

Equivalent to [`date + timedelta(days=n)`](https://docs.python.org/3/library/datetime.html#datetime.timedelta).

## <span style={{ 'color': 'gray' }}>udf</span>  day()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
day(self: pxt.Date) -> pxt.Int
```

Between 1 and the number of days in the given month of the given year.

Equivalent to [`date.day`](https://docs.python.org/3/library/datetime.html#datetime.date.day).

## <span style={{ 'color': 'gray' }}>udf</span>  isocalendar()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
isocalendar(self: pxt.Date) -> IsoCalendar
```

Return a dictionary with three entries: `'year'`, `'week'`, and `'weekday'`.

Equivalent to
[`date.isocalendar()`](https://docs.python.org/3/library/datetime.html#datetime.date.isocalendar).

## <span style={{ 'color': 'gray' }}>udf</span>  isoformat()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
isoformat(
    self: pxt.Date,
    sep: pxt.String = 'T',
    timespec: pxt.String = 'auto'
) -> pxt.String
```

Return a string representing the date and time in ISO 8601 format.

Equivalent to [`date.isoformat()`](https://docs.python.org/3/library/datetime.html#datetime.date.isoformat).

**Parameters:**

* **`sep`** (`pxt.String`): Separator between date and time.
* **`timespec`** (`pxt.String`): The number of additional terms in the output. See the
  [`date.isoformat()`](https://docs.python.org/3/library/datetime.html#datetime.date.isoformat)
  documentation for more details.

## <span style={{ 'color': 'gray' }}>udf</span>  isoweekday()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
isoweekday(self: pxt.Date) -> pxt.Int
```

Return the day of the week as an integer, where Monday is 1 and Sunday is 7.

Equivalent to [`date.isoweekday()`](https://docs.python.org/3/library/datetime.html#datetime.date.isoweekday).

## <span style={{ 'color': 'gray' }}>udf</span>  make\_date()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
make_date(year: pxt.Int, month: pxt.Int, day: pxt.Int) -> pxt.Date
```

Create a date.

Equivalent to [`datetime()`](https://docs.python.org/3/library/datetime.html#datetime.date).

## <span style={{ 'color': 'gray' }}>udf</span>  month()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
month(self: pxt.Date) -> pxt.Int
```

Between 1 and 12 inclusive.

Equivalent to [`date.month`](https://docs.python.org/3/library/datetime.html#datetime.date.month).

## <span style={{ 'color': 'gray' }}>udf</span>  strftime()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
strftime(self: pxt.Date, format: pxt.String) -> pxt.String
```

Return a string representing the date and time, controlled by an explicit format string.

Equivalent to [`date.strftime()`](https://docs.python.org/3/library/datetime.html#datetime.date.strftime).

**Parameters:**

* **`format`** (`pxt.String`): The format string to control the output. For a complete list of formatting directives, see
  [`strftime()` and `strptime()` Behavior](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior).

## <span style={{ 'color': 'gray' }}>udf</span>  toordinal()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
toordinal(self: pxt.Date) -> pxt.Int
```

Return the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1.

Equivalent to [`date.toordinal()`](https://docs.python.org/3/library/datetime.html#datetime.date.toordinal).

## <span style={{ 'color': 'gray' }}>udf</span>  weekday()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
weekday(self: pxt.Date) -> pxt.Int
```

Between 0 (Monday) and 6 (Sunday) inclusive.

Equivalent to [`date.weekday()`](https://docs.python.org/3/library/datetime.html#datetime.date.weekday).

## <span style={{ 'color': 'gray' }}>udf</span>  year()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
year(self: pxt.Date) -> pxt.Int
```

Between 1 and 9999 inclusive.

(Between [`MINYEAR`](https://docs.python.org/3/library/datetime.html#datetime.MINYEAR) and
[`MAXYEAR`](https://docs.python.org/3/library/datetime.html#datetime.MAXYEAR) as defined by the Python `datetime`
library).

Equivalent to [`date.year`](https://docs.python.org/3/library/datetime.html#datetime.date.year).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.