I am trying to find out the number of days it takes to ship orders - but any order placed after 4 pm cannot be shipped the same day and therefore should not have to count the actual CompletedDate as a day.
In essence, if an order that is placed at noon, and ships the same day should have 0 days to ship, but an order placed that same day at 8 pm, then ships the following day should also show 0 days.
I am trying to use an If Statement, so that if the order is placed past 4 pm, then it takes one day off of the shipping days.
The first two entries should both have 0 days to ship - while the last one should have 5.
My problem is referencing time in my If Statement - it doesn't want to recognize the various formats I am trying to use.
It keeps telling me all my orders are after 4 pm, when they aren't. (I tested this by doing an If statement like above, only where the then condition just told me "After 4" instead of doing the equation.)
I was just about to post a (wrong) solution suggesting that you might be comparing strings rather than numbers due to a non-matching TimeFormat variable, when I found your thread already answered correctly.
Just some thoughts to supplement the solution:
CompletedTime - DayStart(CompletedTime)
might as well be calculated as
which extracts the (fractional) time part from a timestamp value.
should be the same as
since the formatting Date()-function does not change the numerical value of a date/timestamp,