Creating Peak and Off Peak Timebands

I have written a formula to split peak from off peak time, peak is only Monday to Friday, the result is only returning data for off peak, please see formula below;

  If ( (time({STAT_RM_TRANSACTIONS.TRIPDATETIME})>=timevalue(03,00,00) AND time({STAT_RM_TRANSACTIONS.TRIPDATETIME})<=timevalue(09,29,59))
          AND  (
          (time({STAT_RM_TRANSACTIONS.TRIPDATETIME})>=timevalue(15,30,00) AND time({STAT_RM_TRANSACTIONS.TRIPDATETIME})<=timevalue(17,59,59))
               )  AND      
          datepart("w",{STAT_RM_TRANSACTIONS.TRIPDATETIME}) IN [2,3,4,5,6] //weekdays
 
         ) THEN "Peak"

ELSE "Off Peak"
judy pritzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
Change your 2nd AND to OR
 you have
if (A >=3 AND A<=9)
AND
A >= 15 AND A<=17)

if A = 15
you get False AND True which means FALSE
 
 
If ( (time({STAT_RM_TRANSACTIONS.TRIPDATETIME})>=timevalue(03,00,00) AND time({STAT_RM_TRANSACTIONS.TRIPDATETIME})<=timevalue(09,29,59))
          OR  (
          (time({STAT_RM_TRANSACTIONS.TRIPDATETIME})>=timevalue(15,30,00) AND time({STAT_RM_TRANSACTIONS.TRIPDATETIME})<=timevalue(17,59,59))
               )  AND      
          datepart("w",{STAT_RM_TRANSACTIONS.TRIPDATETIME}) IN [2,3,4,5,6] //weekdays 
 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
judy pritzAuthor Commented:
Thank you, I knew it was something simple, sometimes you just need a fresh pair of eyes.
0
David Johnson, CD, MVPOwnerCommented:
Logic problems are always the hardest to find. Have a great day.
0
David Johnson, CD, MVPOwnerCommented:
logic error fixed
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.