Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Comparing the Time in ColdFusion
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,
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
For extra credit :)
How would I tell if the current time is after 6:15 am?
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-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.
See how we're fighting big data
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!
I love how date/time stuff usually turns out to be simpler than you think. Three cheers for date/time functions :)
Plans and Pricing
Certified Expert Program
© 1996-2023 Experts Exchange, LLC. All rights reserved. Covered by US Patent