Date addition and subtraction is really much easier than this. CF does a
lot of implicit data type conversion for you.
Instead of
<cfset datetocheck = "#DateFormat("09/02/2000", "mm/dd/yyyy")#">
<cfset currentdate = "#DateFormat(Now(), "mm/dd/yyyy")#">
<cfset lastweekdate = "#DateFormat(currentdate-7, "mm/dd/yyyy")#">
<cfset difference = DateDiff("d", lastweekdate, datetocheck)>
Try
<cfset datetocheck = "9/2/2000">
<cfset lastweekdate = now() - 7>
<cfset difference = lastweekdate - datetocheck>
Accomplishes the same thing unless I got the subtraction reversed . . .
don't use datediff often enough to remember which way it goes. One caveat,
you may need the datediff if the time component decides to interfere with
what you are doing.
Dan
-----Original Message-----
From: Mark Warrick [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 07, 2000 9:48 AM
To: [EMAIL PROTECTED]
Subject: RE: simple date problem major brain fart
This code should do the job:
<cfset datetocheck = "#DateFormat("09/02/2000", "mm/dd/yyyy")#">
<cfset currentdate = "#DateFormat(Now(), "mm/dd/yyyy")#">
<cfset lastweekdate = "#DateFormat(currentdate-7, "mm/dd/yyyy")#">
<cfset difference = DateDiff("d", lastweekdate, datetocheck)>
<cfoutput>
Date to Check: #datetocheck#<br>
Current Date: #currentdate#<br>
Last Week's Date: #lastweekdate#<br>
Difference between last week's date and date to check: #difference#
</cfoutput>
--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------
> -----Original Message-----
> From: Art Broussard [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 07, 2000 8:21 AM
> To: [EMAIL PROTECTED]
> Subject: simple date problem major brain fart
>
>
> Lets say CurrentDate is 9/7/2000 and you need to do a check to see if
> DateToCheck is equal to or greater than CurrentDate - 7 days. if you
> subtract 7 from the days you get 9/0/2000 which is an invalid
> date. Is there
> an easy way to do this?
>
> Please help, my brain is full of gas
>
> Art
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.