Skip to main content
Participant
January 25, 2019
Question

coldfusion 2018 lsparsedatetime issue

  • January 25, 2019
  • 3 replies
  • 611 views

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 has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
January 27, 2019

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

Participant
January 27, 2019

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

BKBK
Community Expert
Community Expert
January 27, 2019

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'}

Inspiring
January 26, 2019

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

Participant
January 27, 2019

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

WolfShade
Legend
January 25, 2019

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,

^ _ ^

Participant
January 25, 2019

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