<x-html><div>At 03:14 PM 4/7/2001 +0100, you wrote:</div>
<blockquote type=cite class=cite cite><div>DateFormat() accepts a date
object and, optionally, the format in which you</div>
<div>want to _display_ the date.</div>
<div>If you pass it a string instead of an actual date object then CF
tries to</div>
<div>convert it to a valid date, first using the mm/dd/yyyy format, and
if that</div>
<div>fails it tries dd/mm/yyyy.</div>
<div>IsDate() does the same sort of thing, and so do some
databases...</div>
<br>
<div>If you get a date passed as a string (eg from a form), then the
_first_</div>
<div>thing you should do IMHO is use CreateDate() to turn it into a date
object.</div>
<br>
<div>And only use DateFormat() when you're displaying a date and not to
set a</div>
<div>variable, because you then run the risk of that variable being
used</div>
<div>incorrectly elsewhere by someone who doesn't know what format mask
you used</div>
<div>when you created the string.</div>
<br>
<div>ie </div>
<div>good: <cfset mydateobject =</div>
<div>CreateDate(ListLast(form.date,'/'),ListGetAt(form.date,2,'/'),ListFirst(form</div>
<div>..date,'/')></div>
<div>good: #DateFormat(mydateobject, 'dd/mm/yyyy')#
</div>
<div>risky: <cfset mydate = DateFormat(mydateobject,
'dd/mm/yyyy')></div>
<div>bad: <cfset mydateobject =
CreateDate(form.date,'dd/mm/yyyy')></div>
<div>bad: IsDate(form.date)</div>
<br>
<div>Bert</div>
<br>
<div>Certified CF Developer who spent a lot of time tidying up shoddy
date</div>
<div>handling written by someone else...</div>
<br>
<div>> -----Original Message-----</div>
<div>> From: Tim Price
[<a href="mailto:[EMAIL PROTECTED]"
EUDORA=AUTOURL>mailto:[EMAIL PROTECTED]</a>]</div>
<div>> Sent: 07 April 2001 09:17</div>
<div>> To: Fusebox</div>
<div>> Subject: Date fields</div>
<div>> </div>
<div>> </div>
<div>> Could anyone shed any light onto why after entering a date of
</div>
<div>> "07/04/2001"</div>
<div>> (dd/mm/yyyy format)the following <cfset</div>
<div>>
display_from=#dateformat(display_from,"dd/mm/yyyy")#></div>
<div>> switches it to "04/07/2001" (this is only used to
redisplay </div>
<div>> it if the form</div>
<div>> is redisplayed follwoing validation failure on any form
field)</div>
<div>> </div>
<div>> ..... unless that is I enter a day > 12 and then it retains
</div>
<div>> its original</div>
<div>> input "13/04/2001"</div>
<div>> </div>
<div>> I also find that if I insert the field into the database
without using</div>
<div>> CreateODBCDate it retains its orginal format but WITH </div>
<div>> CreateODBCDate it</div>
<div>> switches the dd/mm parts round if the dd is < 13</div>
<div>> </div>
<div>> Thanx in advance</div>
<div>> </div>
<div>> Tim Price</div>
<div>> </div>
<div>> </div>
<div>> </div>
<div>></div>
<div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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