How to get today and yesterday in PosgreSQL
Posted: | Categories: tech
Very useful dates functions for PostgreSQL. The official documentation is here. Getting the current date and time SELECT NOW() Getting the current day, no time SELECT date_trunc('day', NOW())::date; One hour later SELECT (NOW() + interval '1 hour') AS one_hour_later; One day later SELECT NOW()+1 The day before SELECT NOW()-1 For more complex calculations you can use intervals For example: SELECT (NOW() + interval '1 day') AS now_but_tomorrow; Other articles for databases geeks Using Athena from the AWS CLI on Linux Getting today in Athena Getting today in PostgreSQL How to get the metadata of AWS Athena tables Get the number of columns in an AWS Athena table Read more...