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

Error in createdatetime

New Here ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

<cfset schedindtl.presstime = 230>
<cfset schedindtl.pressdate = 20090308>
<cfset pressstart = #createdatetime(mid(schedindtl.pressdate,1,4),mid(schedindtl.pressdate,5,2),mid(schedindtl.pressdate,7,2),int(schedindtl.presstime/100),int(right(tostring(schedindtl.presstime),2)),0)#>
pressstart = #pressstart#

Looks like daylight savings time problem. Looking for help in fixing.

Views

3.1K

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 ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

> Looks like daylight savings time problem. Looking for help in fixing.

It'd help if you posted what error you're getting.

That code works fine for me.

You don't need the pound-signs on the third line, btw. This will not
impact your situation at all, but it makes your code look tidier.

--
Adam

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 ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

Here is the error.
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.

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
LEGEND ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

quote:

Originally posted by: djl2445
Here is the error.
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.



You are passing it a string. Not sure why it work for Adam and not for you.

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
Engaged ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

What version of CF? Have the daylight savings time patches been applied to the server? If you do a CFDUMP, what value is being passed to the server?

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 ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

Version 8.0.1 We are looking at the server for patches. Is this to the operatings system or CF8. We didn't find a patch for CF8.

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 ,
Mar 02, 2009 Mar 02, 2009

Copy link to clipboard

Copied

If I change it from 230 to 330 it works. We are looking for fixes to the server OS.

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
Explorer ,
Mar 04, 2009 Mar 04, 2009

Copy link to clipboard

Copied

I am also getting this error. Seems to be a problem with the date 2009-03-08 and time of 2am.

For example:

CreateDateTime(2009, 3, 8, 2, 45, 0)

Will through the following error:

Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.

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
LEGEND ,
Mar 04, 2009 Mar 04, 2009

Copy link to clipboard

Copied

> I am also getting this error. Seems to be a problem with the date 2009-03-08
> and time of 2am.
>
> For example:
>
> CreateDateTime(2009, 3, 8, 2, 45, 0)

In US TZs, there is no 2:45am on March 8. Daylight savings kicks in @ 2am,
and the time automagically becomes 3am. "2009-03-08 02:45:00" does not
exist as a time in the US.

--
Adam

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
Engaged ,
Mar 04, 2009 Mar 04, 2009

Copy link to clipboard

Copied

That date and time is precisely when daylight savings time occurs for the EST time zone in North America. At 2:00 AM it will become 3:00 AM, and therefore 2:00 AM does not exist on 3/8/2009.

I can only guess that this is the rationale for it being an invalid date/time.

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
Explorer ,
Mar 04, 2009 Mar 04, 2009

Copy link to clipboard

Copied

That makes sense to me. Thanks for your assistance.

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
Engaged ,
Mar 05, 2009 Mar 05, 2009

Copy link to clipboard

Copied

It does seem like a more helpful error could be thrown in that instance, doesn't it?

Wait a minute. Wouldn't that time be perfectly valid for the portions of the US that do not observe daylight savings time? Arizona and Hawaii do not observe DST. Indiana did not observe DST until 2005.

CrystalTech, a popular CF webhost, is situated in Arizona, I believe. It would seem to me that the server time would be perfectly valid on those boxes, wouldn't it? Is it simply a matter of not applying the DST patch to those machines?

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
LEGEND ,
Mar 05, 2009 Mar 05, 2009

Copy link to clipboard

Copied

> Wait a minute. Wouldn't that time be perfectly valid for the portions of the
> US that do not observe daylight savings time? Arizona and Hawaii do not observe
> DST. Indiana did not observe DST until 2005.

Yep, and it'll work fine in those TZs. It's only when the server is
configured to be in one of the affected TZs that it's a problem. I'm on
GMT here and the code works fine, because our DLS boundary is different.
29/3/2009 01:30 bombs for me.


> CrystalTech, a popular CF webhost, is situated in Arizona, I believe. It would
> seem to me that the server time would be perfectly valid on those boxes,
> wouldn't it? Is it simply a matter of not applying the DST patch to those
> machines?

If one is serving content across TZs, one should really have the server set
to UTC and have your code offset the time as per requirements. Paul
Hastings might be watching out, and this would be his cue to jump in and
explain all that. He's the expert.

--
Adam

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
LEGEND ,
Mar 05, 2009 Mar 05, 2009

Copy link to clipboard

Copied

>> Wait a minute. Wouldn't that time be perfectly valid for the portions of the
>> US that do not observe daylight savings time? Arizona and Hawaii do not observe
>> DST. Indiana did not observe DST until 2005.

A can't *believe* I didn't have more concerted swipe at you for only
considering USA when made your observation above.

A wasted opportunity!

;-)

--
Adam

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
Engaged ,
Mar 05, 2009 Mar 05, 2009

Copy link to clipboard

Copied

It was not a matter of ethnocentricism. I just know for a fact that CrystalTech is in Arizona and one of the exceptions to DST observations!

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
Engaged ,
Mar 05, 2009 Mar 05, 2009

Copy link to clipboard

Copied

As long as we are thinking global, does CFFLUSH go counter-clockwise south of the equator? Something to think about when programming for a global market.

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
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

I am having a problem here:

 

<cfscript>
writeoutput(createdatetime(2022,03,13,2,0,0));
</cfscript>

 

Got this error:

Date value passed to date function createDateTime is unspecified or invalid.

 

Is this related w/ the JVM that I am using? Please help. 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
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

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 ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

@joseph.yan ,

Does the following help as a workaround?

  • add the timezone flag to java.args in the jvm.config file. For example, I have added:
    -Duser.timezone=Europe/London

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
Explorer ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

@BKBK

I can't change this because the app is running in US/Los Angeles time zone. For our European server everything is working great.

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
Community Expert ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

Oh, what I mean is that you should add your own time-zone to jvm.config. That is,

-Duser.timezone=America/Los_Angeles

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 ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Does that help?

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
Explorer ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Nope. 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
Community Expert ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Did you restart ColdFusion after adding the (JVM time-zone) flag? Restarting is crucial.

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 ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Just to be sure, does the following work?

 

<cfscript>
writeoutput(createdatetime(2022,3,13,2,0,0));
</cfscript>

 

 The documentation on CreateDateTime says its arguments should be integers. So, when you use 03 in place of 3, you are in questionable territory. ColdFusion cannot then offer you any guarantees.

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