Avatar of hefterr
Flag for United States of America asked on

Comparing the Time in ColdFusion

Hi Experts,
I know this must sound simple - but these are the ones I get hung up on.

I have a program where I want to see if the current time is after 6 am (or inversely between 12 midnight and 5:59.9999 am of the current day.

Do you use Datediff?, Datecompare?

Thanks in advance,
ColdFusion Language

Avatar of undefined
Last Comment

8/22/2022 - Mon

Use datePart to get the hour.

<cfif datePart("h", now()) lt 6>
      it's before 6AM
    it's on or after 6AM

Hi agx,
For extra credit :)
How would I tell if the current time is after 6:15 am?

Thank again!

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks much!  When I googled this I saw involved solutions.  Yours are more elegant.

I owe you another 50 points for the extra credit :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

I love how date/time stuff usually turns out to be simpler than you think. Three cheers for date/time functions :)