How can I get the difference between two dates in PL SQL?

How to find the Difference Between 2 dates in PLSQL

  1. Select a.Sent, b.Recd, ((b.Recd-a.Sent)*1440) DIFF. from TableA b, TableB a. where b.type = ‘AAA’
  2. 5/9/2011 5:22:00 PM ‘ But i am not getting :
  3. ((b.Recd-a.Sent)*1440) in minutes. Instead i am getting like.
  4. -000000000 06:48:00. I need the difference of DATE in Minutes only.

How can I compare two dates in Oracle?

When using a literal you must specify your date in the format YYYY-MM-DD and you cannot include a time element. Remember that the Oracle date datatype includes a time element, so the date without a time portion is equivalent to 1995-12-31 00:00:00 .

Can we subtract two dates in SQL?

The DATEDIFF() function returns the difference between two dates.

How do you compare the difference between two dates?

Use the DATEDIF function when you want to calculate the difference between two dates. First put a start date in a cell, and an end date in another….Calculate age in accumulated years, months, and days

  1. Use DATEDIF to find the total years.
  2. Use DATEDIF again with “ym” to find months.
  3. Use a different formula to find days.

How can I compare two dates in SQL?

Here we will see, SQL Query to compare two dates. This can be easily done using equals to(=), less than(<), and greater than(>) operators. In SQL, the date value has DATE datatype which accepts date in ‘yyyy-mm-dd’ format. To compare two dates, we will declare two dates and compare them using the IF-ELSE statement.

How do I get days between two dates in SQL?

The statement DATEDIFF(dd,@fromdate,@todate) + 1 gives the number of dates between the two dates. The statement DATEDIFF(wk,@fromdate,@todate) gives the number of weeks between dates and * 2 gives us the weekend (Saturday and Sunday) count. The next two statements excludes the day if it’s a Saturday or Sunday.