?
Solved

Datecompare compares date AND time - how to compare just date?

Posted on 2004-08-10
10
Medium Priority
?
162 Views
Last Modified: 2013-12-24
I am using datecompare in this manner:

#DateCompare(now(),getDD.DueDate)#

However, I am not getting the results I'm looking for because the date AND time of now() of being compared to just a date and zero hours.  I just want to compare date for date.  How can I fix this?
0
Comment
Question by:theamzngq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 1000 total points
ID: 11765719
try this...

<CFSET datetimestart = "8/08/04 8:15pm">
<CFSET datetimeend = "8/10/04 1:30am">

<CFOUTPUT>
#datediff('d',datetimestart,datetimeend)# days
#evaluate(datediff('h',datetimestart,datetimeend) MOD 24)# hours
#evaluate(datediff('n',datetimestart,datetimeend) MOD 60)# minutes
</cfoutput>
0
 
LVL 15

Assisted Solution

by:tim_cs
tim_cs earned 1000 total points
ID: 11765736
Try this #DateCompare(DateFormat(now(), 'MM/DD/YYYY'), getDD.DueDate)#
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11767178
If you just want the effects of datecompare with date only then use tim_cs's solution.

If you want to be able to fine-control the comparison use datediff.

Here is a page that explains the first parameter to datediff for the different comparisons

http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/functions-pt158.htm
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 2

Author Comment

by:theamzngq
ID: 11767737
This seems to do exactly what I'm looking for:

#DateCompare(CreateDate(year(now()),month(now()),day(now())), getFU.FUDueDate)#
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 11768842
Hello theamzngq!

You can also do it in this manner :

<cfset Date1 = DateFormat(now(),'yyyy/mm/dd')>
<cfset Date2 = DateFormat(getDD.DueDate,'yyyy/mm/dd')>

#DateCompare(Date1,Date2)#

Regards!
eNTRANCE2002 :-)

0
 
LVL 2

Author Comment

by:theamzngq
ID: 11773534
I tried this

#DateCompare(DateFormat(now(), 'MM/DD/YYYY'), getDD.DueDate)#

which is essentially what you have written, only broken up into variables, and it didn't work, which is why I went with the above.
0
 
LVL 15

Expert Comment

by:tim_cs
ID: 11773781
What results did my example give you?  I tested it and it worked fine for me.
0
 
LVL 2

Author Comment

by:theamzngq
ID: 12007532
sorry for the delay, folks.  haven't been at work for a bit...
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question