Skip to main content
Participant
Jan 25, 2019 1:29 PM UTC
Question

coldfusion 2018 lsparsedatetime issue

i have some code which reads a datetime field from an sql database and then formats it using lsparsedatetime.

this has worked for years under previous CF versions and produces

{ts '2018-01-11 08:00:00'}

when passed

2018-01-11 08:00:00.0

read from SQL database.

when passing this in CF2018 it refuses to format it but produces no error just the original 2018-01-11 08:00:00.0

i have set <cfset loc = setlocale("English (UK)")>  on both machines

according to my hosting company the date/time settings are the same on both servers though the old server is running older versions of windows/iis/sql server

but as the db date is the same when retrieved from both databases i can only assume CF is the issue?

any help greatly appreciated

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

BKBK
Community Expert
Community Expert
Jan 27, 2019 1:09 PM UTC

Hi PaulWictyWatson​, it is unclear to me what the problem is. Which date format do you get in CF2018 and which do you expect?

Translate
Participant
Jan 27, 2019 1:44 PM UTC

i get just the field as it comes back from the database in 2018 ie 2018-01-11 08:00:00.0

befoe 2018 i always got

{ts '2018-01-11 08:00:00'}

ie a VALID CF date

Translate
BKBK
Community Expert
Community Expert
Jan 27, 2019 4:26 PM UTC

On CF2018, the code

<cfset setlocale("English (UK)")>

<cfoutput>#lsparsedatetime("2018-01-11 08:00:00.0")#</cfoutput>

gives me

{ts '2018-01-11 08:00:00'}

Translate
Inspiring
Jan 26, 2019 10:31 PM UTC

How does your call to LSParseDateTime look? It accepts up to three arguments?

Translate
Participant
Jan 27, 2019 1:43 PM UTC

no parameters as never needed any before. just lsparsedatetime(queryName.fieldName)

Translate
WolfShade
Legend
Jan 25, 2019 3:34 PM UTC

Have you tried using DateTimeFormat()?

<cfset dttm = DateTimeFormat(#query_timestamp#,'yyyy-mm-dd HH:nn:ss') />

This should give you the format you desire.

V/r,

^ _ ^

Translate
Participant
Jan 25, 2019 3:38 PM UTC

sure, yes there are solutions to code around the issue to get the required result but i have hundreds of places in several client sites that use this simple piece of code thats worked for 17 years!!!

i need a fix that doesnt require a code change

thanks

Translate