Home | Blog | Twitter @AndyJ | Contact Me | Snippets/Downloads | RSS

CreateODBCDatetime tale of caution

I have a scedule task which runs daily and we've noticed that at the begining of the month it has been behaving oddly. Its been changing dates around. i.e its been converting 2006-08-03 to 2006-08-30. Below is an example of whats happend:

Before: {ts '2006-08-01 13:01:00'}   After: {ts '2006-08-10 00:00:00'}

   view plainprintabout
 <cfset dateTest_after = createODBCDateTime(dateFormat(now(), 'yyyy-mm-dd')&'00:00:00') />
After spending considerable amount of time today thinking this was a CF bug and testing/re-testing my problem. I was stuck. The code worked fine for the other 27/28 days of the month. In the end I found out it was the lack of a space " " between date and time which caused this problem at the begining of the month. So it should read:
   view plainprintabout
 <cfset dateTest_after = createODBCDateTime(dateFormat(now(), 'yyyy-mm-dd')&' 00:00:00') />
Painful its been, but a lesson to pass on
TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC / created by Raymond Camden / running version 5.9.5.003 / Contact AndyJarrett.com / Pet Rescue SOS www.redgiraffes.co.uk