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

Error in createdatetime

New Here ,
Mar 02, 2009 Mar 02, 2009
<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.
3.7K
Translate
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
> 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
Translate
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
Here is the error.
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.

Translate
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
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.
Translate
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
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?
Translate
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
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.
Translate
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
If I change it from 230 to 330 it works. We are looking for fixes to the server OS.
Translate
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
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.

Translate
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
> 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
Translate
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
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.
Translate
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
That makes sense to me. Thanks for your assistance.
Translate
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
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?
Translate
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
> 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
Translate
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
>> 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
Translate
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
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!
Translate
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
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.
Translate
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

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.

Translate
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
Translate
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

@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
Translate
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

@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.

Translate
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

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

-Duser.timezone=America/Los_Angeles

Translate
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

Does that help?

Translate
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

Nope. Thanks.

Translate
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

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

Translate
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

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.

Translate
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