Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking: date/time functions #8849

Open
16 of 17 tasks
xiangjinwu opened this issue Mar 29, 2023 · 1 comment
Open
16 of 17 tasks

Tracking: date/time functions #8849

xiangjinwu opened this issue Mar 29, 2023 · 1 comment

Comments

@xiangjinwu
Copy link
Contributor

xiangjinwu commented Mar 29, 2023

https://www.postgresql.org/docs/current/functions-datetime.html

Caveats:

  • A month can have 28, 29, 30, or 31 days.
  • A day may have 23 or 25 hours during Daylight Saving Time switch.
  • The same instant may have a different reading of year (or month, day, hour, minute, second) in different zones.
  • PostgreSQL does not handle leap seconds.
  • PostgreSQL uses the proleptic Gregorian calendar rather than the Julian calendar for dates before 1582-10-15.
  • ISO 8601 year 0 is generally referred to as 1 BC

proto ExprType 101..=108

Cast

  • implicit: date -> timestamp -> timestamptz
  • implicit: time -> interval
  • assign: timestamptz -> timestamp -> date
  • assign: interval -> time
  • assign: timestamptz -> time
  • assign: timestamp -> time

Arithmetic operators

Basic

Formatting

Current

  • current_timestamp / transaction_timestamp() / now() -> timestamptz
  • localtimestamp -> timestamp
  • current_date -> date / age(timestamp) -> interval / age(timestamptz) -> interval
  • localtime -> time

Nonstandard:

  • statement_timestamp() -> timestamptz
  • clock_timestamp() -> timestamptz / timeofday() -> varchar
  • 'now' / 'today' / 'tomorrow' / 'yesterday'

No support

Aggregate

  • sum / avg for interval

Set Returning Functions

  • generate_series(start T, stop T, step INTERVAL) -> setof T where T is timestamp / timestamptz
@github-actions github-actions bot added this to the release-0.19 milestone Mar 29, 2023
@xiangjinwu xiangjinwu removed this from the release-0.19 milestone Apr 4, 2023
@matanper
Copy link

matanper commented Oct 3, 2023

Is it possible to add to the list date_diff?
Current alternative is taking the epoch and then subtracting by given unit you want:

(EXTRACT(EPOCH FROM date2 - date1) / 86400)::int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants