Postgresql timestamp minus minutes9/23/2023 But if we use it with the + operator, then it will be subtracted from the input date/time. If we use a negative value with the - operator, then the specified number of hours will be added to the input date/time. It’s possible to perform date arithmetic with negative values. If the hours to be subtracted are in 24 hour increments, we can alternatively use days: SELECT timestamp ' 15:45' - interval '1 day' We can alternatively subtract the equivalent number in minutes: SELECT time '15:45' - interval '120 minutes' We can also add a date and time value together, and subtract hours from that: SELECT date '' + time '03:00' - interval '2 hours' From: pgsql-general-owner(at)postgresql(dot)org mailto:pgsql-general-owner(at)postgresql(dot)org On Behalf Of Brandon Metcalf Sent: Thursday, Febru1:56 PM To: pgsql-general(at)postgresql(dot)org Subject: GENERAL subtracting minutes from date. We can even subtract hours from a date value: SELECT date '' - interval '8 hours' We can also subtract hours from an interval: SELECT interval '5 hours' - interval '2 hours' So to subtract one or more hours, we can use hour or hours: SELECT time '07:00' - interval '1 hour' Īnd in plural form: SELECT time '07:00' - interval '2 hours' Īnd here it is with a timestamp value: SELECT timestamp ' 09:00' - interval '30 hours' We can specify intervals when performing arithmetic against dates and times. We can also subtract hours from a date value or a date and time combination. In PostgreSQL, we can use the - operator to subtract one or more hours from a time value.īy “time” value, this could be an actual time value, a timestamp, or an interval.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |