![]() ![]() The tricky thing about dates is that their formats vary in different countries, so it can be quite a challenging task for beginners in database management. You can use dates and timestamps for data analysis and data storage, as they allow you to determine when an event actually occurred. We will be using dbForge Studio for PostgreSQL to illustrate the examples. 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.In this article, we will look into working with dates in PostgreSQL, including the various date data types and formats, their functions, and the ways how to deal with them in your everyday routine. 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. |