• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

coldfusion 2018 lsparsedatetime issue

New Here ,
Jan 25, 2019 Jan 25, 2019

Copy link to clipboard

Copied

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

Views

346

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 25, 2019 Jan 25, 2019

Copy link to clipboard

Copied

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,

^ _ ^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 25, 2019 Jan 25, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 26, 2019 Jan 26, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation