Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 457
  • Last Modified:

Coldfusion MX and Daylight Savings

I am running Coldfusion MX 7.0.2 on a fully patched Windows 2003 server.  I am running Java Version
1.4.2_11-b06 on the server.  I am querying data from an Oracle database.  If I view the Oracle data in something like Access the times are displayed correctly because Office doesn't account for DST.  Basically I have a value that is read every hour so each day has 24 readings.  My problem is that readings between November 4, 2007 and March 9, 2008 all are offset by 1 hour which messes up my data.  I've installed al the DST patches for Java and Coldfusion but it doesn't seem to help.  I also tried using <cfif> statements to evaluate the dates like <cfif newdate GT 11042007 LT 03092008> but no matter how I format or convert the dates it will not evaluate them and this portion of my code is basically skipped.  What I need is actually simple.  I want Coldfusion to completely ignore DST.  I just want it to read the database and return exactly what is there with no conversion but even if I do a to_char it still apparently applies DST before the conversion.  How can I disable DST changes altogether or is there something else I can do to fix this problem?

To get my data I am using the following SQL statement.
WHERE read_time BETWEEN TO_DATE ('#readtime# 00', 'yyyy/mm/dd hh24') AND TO_DATE ('#readtime# 23', 'yyyy/mm/dd hh24')
This gives me the correct data for today for example but anything in the range I listed above is off by an hour.  

0
KCody
Asked:
KCody
  • 2
  • 2
1 Solution
 
SidFishesCommented:
you can check to make sure that cf is actually -using- the correct jvm as multiples can be installed

run this bit

<cfset sys=CreateObject("java","java.lang.System")>
<cfoutput>
<p>You are running
   <strong>#sys.getProperty("java.vendor")#</strong>
   jvm version
   <strong>#sys.getProperty("java.version")#</strong>.
</p>
<hr />
</cfoutput>

afaik there's no way to -ignore- the dst patch (and I really can't imagine a reason why you'd want to)
0
 
KCodyAuthor Commented:
Here is the result I get when I run your code:
You are running Sun Microsystems Inc. jvm version 1.4.2_11.

DST is working properly, I guess what I need to know is how do I evaluate dates that fall within the DST range and add an hour to them so they will report correctly?
0
 
SidFishesCommented:
just use dateadd example using a temp query object

<cfset TempQry= querynew("")>
 <cfset queryaddcolumn  (TempQry, "Col1", "CF_SQL_integer", ListToArray("1,2,3"))>
<cfset queryaddcolumn  (TempQry, "Col2", "cf_sql_date", ListToArray("06/01/2008 12:00, 02/01/2008 12:00, 12/20/2007 12:00"))>
 
<cfloop query="tempqry">
<cfset d1 = dateadd("h",1,col2)>
<cfoutput>
#col2#: #d1#<br></cfoutput>
</cfloop>

and using between so only the 2 early dates are affected

<cfset TempQry= querynew("")>
 
<cfset queryaddcolumn  (TempQry, "Col1", "CF_SQL_integer", ListToArray("1,2,3"))>
<cfset queryaddcolumn  (TempQry, "Col2", "cf_sql_date", ListToArray("06/01/2008 12:00, 02/01/2008 12:00, 12/20/2007 12:00"))>
 <cfquery name="q2" dbtype="query">
select * from tempqry where col2 between '11/04/2007' and '03/09/2008'
</cfquery>
<cfloop query="q2">
<cfset d1 = dateadd("h",1,col2)>
<cfoutput>
#col2#: #d1#<br></cfoutput>
</cfloop>

0
 
KCodyAuthor Commented:
What you wrote may work but I can't get it to work with my application.  If I could see an easy example of evaluating date values from an Oracle source it would really help me out.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now