createodbcdatetime() - a weird one!

ColdFusion Add comments

I ran into a interesting issue/bug today with cfdirectory and createodbcdatetime(). To demonstrate, below are the outputs of exactly the same code one running on CF7.01 and the other on CF6.1. The first column is the raw datelastmodified field returned from the cfdirectory whilst the second column is the value returned from createdatetime() on the datelastmodified field, both running on the same server

On CF7.01 it would appear that createodbcdatetime() is not obeying the server locale instead defaulting to US format, hence why my file 29/03/05 (29 March 2005) appears to have time warped to 2029!!

cfdirectory results on ColdFusion 7.01

06/04/05 08:16 {ts ‘2005-06-04 08:16:00′}
29/03/05 11:12 {ts ‘2029-03-05 11:12:00′}
15/06/05 11:14 {ts ‘2015-06-05 11:14:00′}
10/11/05 08:22 {ts ‘2005-10-11 08:22:00′}

cfdirectory result on ColdFusion 6.1

06 April 2005 08:16:51 o’clock BST {ts ‘2005-04-06 08:16:51′}
29 March 2005 11:12:38 o’clock BST {ts ‘2005-03-29 11:12:38′}
15 June 2005 11:14:20 o’clock BST {ts ‘2005-06-15 11:14:20′}
10 November 2005 08:22:58 o’clock GMT {ts ‘2005-11-10 08:22:58′}

There’s nothing in livedocs to suggest a change of behaviour between versions - so it’s left me stumped. A fix is to use lsparsedatetime() instead but it seems odd it’s changed without notification..?

4 Responses to “createodbcdatetime() - a weird one!”

  1. Christopher Wigginton Says:

    Not sure the lsParseDateTime is going to do it.
    According to your cfdirectory dump, the timezone is preserved in the 6.1, but not in 7. This means that the three files in BST (British Summer Time) are actually (GMT+1).

    You might have to resort to a com fsobject and work with the dates on the files directly.

  2. speelman Says:

    Is the CF7.01 machine running on the same OS and international settings as the machine running 6.1 ?

  3. johnb Says:

    yep, my laptop - two instances running on Jrun4

  4. Forb Says:

    thx

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in