Sunday, September 28, 2008

ColdFusion Daylight saving bug (feature?)

Well just got back from the weekend to find a nice bug with a date time created in a query.

Date value passed to date function CreateDateTime is unspecified or invalid.

This was pretty strange since this function had been called for the last 3 months each day so obviously was a daylight savings issue. I pinned it down to on CreateDateTime function:

CreateDateTime(2008, 9, 28, 2, 0, 0);

What the issue is that this is an invalid date time since this time does not exist but honestly throwing an invalid date error is pointless. This is noted in the ColdFusion LiveDocs in the comments. But in hindsight I should check for this date time to make the query more robust. Though checking the datatime is valid every time I create a date time is a waste of processing power in my mind.

So the only solution available is a try{...} catch(){...} solution which I think is poor.

try {
dateTime = CreateDateTime(2008, 9, 28, 2, 0, 0);
} catch(Any exception) {
// Blank the result - Daylight saving issue
dateTime = CreateDateTime(2008, 9, 28, 0, 0, 0);


Anonymous said...

Parsing (listToArray, etc.)


...appear to croak it as well.

This is quite un-cool...there are parts of the country that do _not_ support DST, so to mandate this in this function seems unreasonable.

There should at least be a switch of some sort to control this behavior.

Thank you very much for your note, this was driving me nuts.

Anonymous said... more note:

I'm importing data from a non-DST observing source. It also appears that CreateODBCDateTime and every other date and time function does so too.

I wound I need to distinguish, for instance, between 02:00 and 03:00 on 2 April 2006...just manually creating date-times!

Nice! Progress! ;-)

Thanks again for your note, I'm glad I quickly gave up and hit the web. ;-)