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
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,
^ _ ^
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
Copy link to clipboard
Copied
How does your call to LSParseDateTime look? It accepts up to three arguments?
Copy link to clipboard
Copied
no parameters as never needed any before. just lsparsedatetime(queryName.fieldName)
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?
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
Copy link to clipboard
Copied
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'}