> > The DateAdd function et al are designed to do date manipulation,
> painlessly.
>
> I had a look at the DateAdd documentation, but the example wasn't much
help.
> Do you have any tips as to how I can define next week's date, based on
> today's?

For working with dates, you should probably first be using a format that CF
recognizes as a date.  CF is very flexible in parsing strings and
automatically converting them to date/time values.  Your 'ddmmyyyy' format
won't work.  Although it's easy to convert that string into a date when you
need to manipulate it, it's generally easier if the variable store a valid
date, then use DateFormat() whenever you nee to view the date in some
specific output format.

Use CF's IsDate() function to see if a variable contains a date/time.

<cfset dt = "04112000">
#IsDate(dt)#    <!--- evaluates to false --->

If you wanted, you could convert a string of that format to a date with:

<cfset newdt = CreateDate(Mid(dt, 5, 4), Mid(dt, 3, 2), Mid(dt, 1, 2))>

Once you've got a valid date, add a time span to the variable with the
DateAdd() function.

<cfset futuredt = DateAdd("d", 7, newdt)> <!--- add 7 days --->

For ODBC queries, you should be using ODBC formatted dates.  Once again, you
need to start with a valid date/time.

<cfset today = "11-04-2000">  <!--- this format is OK with CF --->

<cfquery name="myquery" datasource="#mydsn#">
SELECT *
FROM mytable
WHERE thedate = #CreateODBCDate(DateAdd("d", 7, today))#
</cfquery>


Jim

------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to