How can I get a timestamp with a date 30 days from now?
I tried things like now() + integer '30'... but it didn't work.
I'm running Postgres 8.
Any ideas?
The next major release of PostgreSQL is planned to be the 16 release. A tentative schedule for this version has a release in the third quarter of 2023.
Timestamp vs Timestamptz – What's the Difference? The big difference between these two data types is that timestamptz includes a timezone offset while timestamp does not. So it is important to decide for the timestamp you are storing whether the timezone is important to keep or not.
PostgreSQL supports the full set of SQL date and time types, shown in Table 8.9.
PostgreSQL stores the timestamptz in UTC value. When you insert a value into a timestamptz column, PostgreSQL converts the timestamptz value into a UTC value and stores the UTC value in the table.
Try something like this:
SELECT NOW() + '30 days'::interval
The standard SQL expression is
select current_timestamp + interval '30' day
Quotes around the number, not around the phrase. See the earliest SQL standard I can find online, p 91. PostgreSQL is much more flexible than the standard, which can be a good thing or a bad thing. I support a lot of different dbms--the flexibility hurts me more often than it helps. PostgreSQL, for example, supports this non-standard statement.
select current_timestamp + interval '1 month, 2 days, 3 hours, 2 minutes';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With