![]() ![]() Step 1: Subtract the hours, we get 5 – 2 = 3 hours. Subtract 5 hours 48 minutes and 2 hours 12 minutes. Subtraction of Hours, Minutes, and Seconds Examples Subtract the seconds and if the number of seconds is negative then add 60 seconds and subtract 1 minute.ĭo Read: Conversion of Hours into Minutes.Subtract the minutes and if the number of minutes is negative then add 60 minutes and subtract 1 hour.The first and foremost step write down the highest given time on the top and lowest time below to perform subtraction. How to Subtract Hour, Minutes, and Seconds?įollow the below steps to subtract an hour, minutes, and seconds. A unit of time equal to 60 seconds is called a minute.A period of time equal to 1/24 of a day is called an hour.It is measured using years, months, weeks, days, hours, minutes, and seconds. The sequence of events that takes place in the present, past, and future is known as Time. By using some examples you will get to know about conversion and the subtraction of time.Īlso, See: Addition of Hours, Minutes, and Seconds In this article, we will know how to subtract time accurately by using step by step procedure mentioned in the article. This also involves the conversion of time i.e hours to minutes, minutes to seconds, and hours to seconds. However, subtracting the time is very useful in our daily life. 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.Learn how the Subtraction of Hours, Minutes, and Seconds will work. 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. |