Try this Data want ; Set have ; If Missing (ORD_ENTRY_DATE) Or Missing (DLVR_STRT_DTS) Or DLVR_STRT_DTS < ORD_ENTRY_DATE Then Do ; Output ; /* Missing value for Hours */ Return ; End ; Time = 0 ; Date = ORD_ENTRY_DATE ; Do until (Date >= DLVR_STRT_DTS) ; End_Date = MIN(DLVR_STRT_DTS, INTNX ('DTDAY', Date, 1)) ; If Weekday (Datepart (Date)) in (1, 7) ; /* Weekend */ Else Time + (End_Date - Date) ; /* Seconds */ Date = End_Date ; End ; Hours = INT (Time / 3600) ; Output ; Drop Date Time End_Date ; Run ; Alert - untested code. The first part of the code tests for invalid values and returns a missing value . The next part tests whether the date is a weekend day, and if not calculates the time in seconds from the start to the end (either midnight, or the given order and delivery timestamps). Richard
... View more