![]() When invoked with the TIMESTAMP form of the second argument, AGE() subtract arguments, producing a "symbolic" result that uses years and months and is of type INTERVAL. Test for finite date, time and interval (not +/-infinity)ĪGE(timestamp, timestamp), AGE(timestamp) S. The following is the list of all important Date and Time related functions available. Interval '1 hour' / double precision '1.5' The following table lists the behaviors of the basic arithmetic operators − Operatorĭouble precision '3.5' * interval '1 hour' Now, let us see the Date/Time operators and Functions. The minus “-” operator has extended functionalities, however, in this post, we have explained a few use cases of the “-” operator, such as how to subtract minutes from a time, date, timestamp, or interval using the “-” operator.We had discussed about the Date/Time data types in the chapter Data Types. We can specify the intervals while subtracting the DateTime values. Where the DateTime value can be a date, interval, time, or timestamp. In PostgreSQL, the “-” operator is used to subtract minutes from the current or specific DateTime values. “380” seconds have been subtracted from the given minutes. In the below code, “130” seconds are subtracted from the given minutes using the “-” operator: SELECT TIME '00:09:00' - INTERVAL '380 Seconds' The output demonstrates that the specified minutes have been successfully subtracted from the current date.Įxample 7: Subtracting Seconds From Specific Minutes In the below snippet, “75” minutes are subtracted from the current date using the “-” operator: SELECT CURRENT_DATE - INTERVAL '75 Minutes' “17” minutes have been successfully subtracted from the given interval using the “-” operator.Įxample 6: Subtracting Minutes FROM Current Date Let’s learn how to subtract minutes from a specific interval using the “-” operator: SELECT INTERVAL '5 years 4 days 2 hours 10 minutes' - INTERVAL '17 Minutes' In this example, “15” minutes are subtracted from the current timestamp: SELECT CURRENT_TIMESTAMP - INTERVAL '15 Minutes' įifteen minutes have been successfully subtracted from the current timestamp.Įxample 5: Subtracting Minutes From a Specific Interval The specified minutes have been successfully subtracted from the given timestamp.Įxample 4: Subtracting Minutes From Current Timestamp Let’s learn how to subtract “55” minutes from a particular timestamp: SELECT TIMESTAMP ' 23:30:30' - INTERVAL '55 Minutes' ![]() The specified minutes have been subtracted from the current time.Įxample 3: Subtracting Minutes From a Specific Timestamp In the following example code, “15” minutes are subtracted from the current time: SELECT CURRENT_TIME,ĬURRENT_TIME - INTERVAL '15 Minutes' AS subtracted_time Nineteen minutes have been subtracted from the given time.Įxample 2: Subtracting Minutes From Current Time In the above snippet, the TIME and INTERVAL represent built-in temporal data types. In the below coding example, “19” minutes are subtracted from the given time: SELECT TIME '03:08' - INTERVAL '19 Minutes' We can specify the intervals while subtracting the DateTime values.Įxample 1: Subtracting Minutes From a Specific Time To subtract minutes from a time, specify the “-” sign between the given times. ![]() How to Subtract Minutes From a Time Using “-” Operator? The minus “-” operator has extended functionalities, however, this write-up explains how to subtract minutes from a time, date, timestamp, or interval using the “-” operator. Minus “-” is one of the built-in Postgres operators that allow us to subtract the specific minutes from a DateTime value. The built-in functions and operators of Postgres allow us to perform numerous tasks on DateTime values. Postgres offers numerous temporal data types that assist us in storing or manipulating the DateTime values efficiently.
0 Comments
Leave a Reply. |