I think what's happening is that you're misusing the dateformat() function: it expects 
a date object, but you're passing it a string. 
DateFormat() misguidedly (IMHO) does its best to convert the string into a date, first 
using the US month/day/year format, and when that fails, it tries the english 
day/month/year format.
Once it has a something it can use as a date then it formats it to the mask you 
specify.

To avoid this sort of thing, always pass around dates as actual date objects, and only 
use the DateFormat when dumping a date onto a page, and when you need to do dB stuff 
then CreateODBCDate should do the trick.

If you have users inputting dates, then as _soon_ as you get them, use CreateDate() to 
create a date object.

This way you know that any dates you are handling are date objects rather than 
strings, and you shouldn't run into this sort of unexpected behaviour.

HTH.

Bert


> -----Original Message-----
> From: INGECOM - D. Delcomminette [mailto:[EMAIL PROTECTED]]
> Sent: 14 February 2001 14:05
> To: CF-Talk
> Subject: Dateformat behaviour
> 
> 
> Have a strange behaviour of DateFormat() function. Look at 
> the following
> code and the results below. In my opinion CF could give me an 
> error message
> on the second line (invalid date) but certainly not invert 
> the day and month
> as it does!
> 
> Your comments?
> 
> Dominique
> 
> 
> <cfoutput>
> <TABLE border="1">
> 
>   <TR>
>     <TD>Dateformat("01/12/2000","yyyymmdd")</TD>
>     <TD>#Dateformat("01/12/2000","yyyymmdd")#</TD></TR>
>   <TR>
>     <TD>Dateformat("13/12/2000","yyyymmdd")</TD>
>     <TD>#Dateformat("13/12/2000","yyyymmdd")# </TD></TR></TABLE></P>
> 
> </CFOUTPUT></P>
> 
> 
> Dateformat("01/12/2000","yyyymmdd")
> 20000112
> Dateformat("13/12/2000","yyyymmdd")
> 20001213
> 
> 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to