Home > database >  Oracle date calculation is the number of days
Oracle date calculation is the number of days

Time:04-11

Such as:
Oracle database, the date in the table 1: the 2021-04-10 12:30:01 date in the table 2, 2021-04-11 00:00:00

Vary the number of days 2 and date the date calculation for 1.

Add and subtract but in SQL directly phase as the decimal 0.479...


So, could you tell me how to solve?

(according to the mysql database operation, can put the date into (date) (month) (year), in the days to calculate)

CodePudding user response:

My idea is:
1 with to_char first, two dates into string - (date) (month) (year) 2021-04-10 and 2021-04-11
2 reoccupy to_date, two strings into date - date 2021-04-10 00:00:00 and 2021-04-11 00:00:00
3 put two dates for subtracting the date date of two minus one equals 1 day

CodePudding user response:

You, about date in oracle is presupposed, calculate the number of days, have what good method, can ignore the split second, when the direct calculation do day?
  • Related