Calculate business days in Oracle SQL(no functions or procedure)

The solution, finally: SELECT OrderNumber, InstallDate, CompleteDate, (TRUNC(CompleteDate) – TRUNC(InstallDate) ) +1 – ((((TRUNC(CompleteDate,’D’))-(TRUNC(InstallDate,’D’)))/7)*2) – (CASE WHEN TO_CHAR(InstallDate,’DY’,’nls_date_language=english’)=’SUN’ THEN 1 ELSE 0 END) – (CASE WHEN TO_CHAR(CompleteDate,’DY’,’nls_date_language=english’)=’SAT’ THEN 1 ELSE 0 END) as BusinessDays FROM Orders ORDER BY OrderNumber; Thanks for all your responses !

How do I find the time difference between two datetime objects in python?

>>> import datetime >>> first_time = datetime.datetime.now() >>> later_time = datetime.datetime.now() >>> difference = later_time – first_time datetime.timedelta(0, 8, 562000) >>> seconds_in_day = 24 * 60 * 60 >>> divmod(difference.days * seconds_in_day + difference.seconds, 60) (0, 8) # 0 minutes, 8 seconds Subtracting the later time from the first time difference = later_time – first_time … Read more

How to find the duration of difference between two dates in java?

The date difference conversion could be handled in a better way using Java built-in class, TimeUnit. It provides utility methods to do that: Date startDate = // Set start date Date endDate = // Set end date long duration = endDate.getTime() – startDate.getTime(); long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration); long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration); long diffInHours = TimeUnit.MILLISECONDS.toHours(duration); … Read more

Calculating days between two dates with Java

UPDATE: The original answer from 2013 is now outdated because some of the classes have been replaced. The new way of doing this is using the new java.time classes. DateTimeFormatter dtf = DateTimeFormatter.ofPattern(“dd MM yyyy”); String inputString1 = “23 01 1997”; String inputString2 = “27 04 1997”; try { LocalDateTime date1 = LocalDate.parse(inputString1, dtf); LocalDateTime … Read more