We can use the -
operator to subtract one or more weeks from a date in PostgreSQL.
Tag: psql
Get the Last Day of the Month in PostgreSQL
We can use the following technique in PostgreSQL to return the last day of a given month.
This could be the last day of the current month, or the last day of the month based on a date that we specify.
Continue readingSubtract Months from a Date in PostgreSQL
In PostgreSQL, we can use the -
operator to subtract one or more months from a date.
Return the Unix Timestamp in PostgreSQL
In PostgreSQL, we can use the extract()
function along with the epoch
argument to return the Unix timestamp.
We can return the Unix timestamp based on the current date/time, or we can get it based on another specified date/time.
Continue readingSubtract Minutes from a Time Value in PostgreSQL
In PostgreSQL, we can use the -
operator to subtract one or more minutes from a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also subtract minutes from a date
value or a date
and time
combination.
Get the Number of Days in a Month in PostgreSQL
Here’s an example of using PostgreSQL to return the number of days in a month, based on a given date.
Continue readingUPPER() – Convert to Uppercase in PostgreSQL
In PostgreSQL, we can use the upper()
function to convert lowercase characters to their uppercase equivalent, according to the rules of the database’s locale.
LOWER() – Convert to Lowercase in PostgreSQL
In PostgreSQL, we can use the lower()
function to convert uppercase characters to their lowercase equivalent, according to the rules of the database’s locale.
Get the First Day of the Month in PostgreSQL
We can use the following method in PostgreSQL to return the first day of a given month.
This could be the first day of the current month, or the first day of the month based on a date that we specify.
Getting the first day of the month allows us to perform further calculations on the resulting date, like adding a certain number of days to the start of the month, etc.
Continue readingAdd Hours to a Time Value in PostgreSQL
In PostgreSQL, we can use the +
operator to add one or more hours to a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also add hours to a date
value or a date
and time
combination.