In PostgreSQL, the justify_hours()
function allows you to adjust an interval value, so that 24-hour time periods are represented as days.
For example, if you have an interval of say, 24 hours justify_hours()
will return it as 1 day.
In PostgreSQL, the justify_hours()
function allows you to adjust an interval value, so that 24-hour time periods are represented as days.
For example, if you have an interval of say, 24 hours justify_hours()
will return it as 1 day.
In PostgreSQL, the isfinite()
function tests for a finite date, timestamp or interval.
This can be useful, because Postgres supports infinite dates/timestamps. For example, you could have a timestamp of infinity or negative infinity, and this function allows you to test for that.
Continue readingIn PostgreSQL, the pg_typeof()
function allows you to get the data type of any value.
More specifically, it returns the OID of the data type of the value that is passed to it. It returns a regtype
, which is an OID alias type. Therefore it’s the same as an OID for comparison purposes but displays as a type name.
In PostgreSQL, clock_timestamp()
is a non-SQL-standard time function that returns the current date and time.
An important consideration of this function is that its result changes throughout the execution of a statement. Therefore, you could get a different result in different parts of the statement if you call the function multiple times within a single statement.
Continue readingIn PostgreSQL, you can use the pg_sleep()
function to delay execution for a given number of seconds.
It makes the current session’s process sleep until the specified number of seconds have elapsed. It works similar to MySQL‘s sleep()
function, and also TSQL‘s waitfor
statement in SQL Server.
The pg_sleep()
function accepts a double precision argument, so you can also specify fractional-second delays.
The sleep delay will be at least as long as specified. However, it could be longer depending on factors such as server load, as well as your platform’s effective resolution of the sleep interval.
Continue readingIn PostgreSQL, you can use the pg_sleep_for()
function to delay execution for a given interval.
It makes the current session’s process sleep until the specified interval has elapsed.
The sleep delay will be at least as long as specified. However, it could be longer depending on factors such as server load, as well as your platform’s effective resolution of the sleep interval.
Continue readingIn PostgreSQL, you can use the pg_sleep_until()
function to delay execution until a specified timestamp.
This is useful for when a specific wake-up time is desired.
Note that pg_sleep_until
is not guaranteed to wake up exactly at the specified time, but it will not wake up any earlier.
In Postgres, the age()
function returns the age based on two timestamp or date variables.
The result is returned using years and months, rather than just days.
For example, a result might look like this: 3 years 2 mons 30 days.
Continue readingIn PostgreSQL, you can get the day name from a date by using the to_char()
function. This function returns a string based on the timestamp and the template pattern you provide as arguments..
In PostgreSQL you can use the extract()
function to get the year from a date.
You can also use the date_part()
function to do the same thing.