Why is there an offset when using DateConvert with DateCompare?

I'm developing on my local server and my current timezone is GMT +11 hours.
<cfset date1 = DateConvert("Local2UTC", now())>
<cfset date2 = '2014-03-06'> <!--- (Tomorrow at time of writing) --->
So, I was expecting that when I ran this code:
#DateCompare(date1,date2,'d' )#
that it would return a "-1" but it returned a "0" implying that the "day" was the same.
So, to double check I output:
DateConvert("Local2UTC", now())
grabbed its displayed value : {ts '2014-03-05 07:08:58'} and inserted that for comparison thus:
DateCompare("{ts '2014-03-05 07:08:58'}",date2,'d' ) and sure enough, it did return a "-1" reflecting that the day of date1 is indeed earlier than date 2.
Further investigation showed that  I had to add my timezone difference to date2 in hours thus:
<cfset date2 = '2014-03-06 11:00:00> to get
#DateCompare(date1,date2,'d' )#
to return a "-1".
Is this a bug or am I misinterpreting??

Hmmm, like with like and all other good practices aside, there is a bug. Also, like just about everyone else, I develop locally in one timezone +10 hours and run my sites remotely on a different timezone -5 hours, altogether a significant time difference. So after coming to understand how to deal with the bug I've come up with a way to compare dateTimes on the remote server, but it does require a spot of copying a string in where you've been advising not to.
First, to the dateCompare() bug. To expose the bug we better use a finer increment than days, so instead of specifying, simply leave the “datepart” attribute empty so that it defaults to seconds. You say you’re in a +1hour timezone so try this.
Presuming a local time of 16:00 on August 7th 2014
<cfset date1 = DateConvert('local2Utc', now())>
<cfdump var="#date1#"> should produce {ts '2014-08-07 15:00:00'}
Now create a dateTime using CreateDateTime(2014,08,07,15,30,00) This time half way between your local dateTime and UTCDateTIme.
<cfset date2 = CreateDateTime(2014,08,07,15,30,00)>
Now compare them <cfdump var="# DateCompare(date1, date2 )#> in this example on your local server, you would expect to return a -1 since date1 is earlier, but in fact it will return a +1 because it seems to be somehow only looking at the now() time (later) instead of the UTC converted time. This is a bug, DateCompare should not care where it gets its data from it should simply get it and then compare the two values. Usually there is no problem using dateCompare but when used in conjunction with the DateConvert('local2Utc', now()) it ignores the value generated by the conversion. Anyway, so much for the bug, Now to the procedure that I’m using that requires copying a string.
I’m wishing to compare a dateTime that I want something to stop being displayed on the remote server.
<cfset myDate = CreateDateTime(2014,08,05,17,0,0)>
<cfset myDateInUTC = DateAdd("s", GetTimeZoneInfo().UTCTotalOffset, myDate)>
<cfdump var="#myDateInUTC#">
This produces the string: {ts '2014-08-15 07:00:00'} .
I then generate currentUTCDateTime from:
<cfset currentUTCDateTime = DateAdd("s", GetTimeZoneInfo().UTCTotalOffset, now())>
Both these dates are then compared thus:
DateCompare(currentUTCDateTime, "{ts '2014-08-07 15:00:00'}" )
I have to generate the string on my local server and then upload it which is why I’m unable to simply use a function. It’s a bit convoluted but it does work. Note that in this example I’m setting the currentUTCDateTime using DateAdd instead which doesn’t trip up like DateConvert.

Similar Messages

  • Why is there an echo when using FaceTime on my Mac Book Pro?

    Why is there reverb when using FaceTime on my mac book pro?

    Sounds just the same and as bad with headphones/headset as from internal speaker. Others have reported this problem. Has a solution been found yet?

  • When phone not muted, why isn't there any audio when using facetime?

    When phone not muted, why isn't there any audio when using facetime?

    What version of iMovie?
    What camera?

  • Why won't cells autopopulate when using numbers on the ipad? Anyone have a fix? Have also created a dropdown menu, but that does not translate from excel to numbers either.

    Why won't cells autopopulate when using numbers on the ipad as they will in excel? Anyone have a fix? I have also created a dropdown menu in excel, but that does not translate from excel to numbers either.

    Glad you got it sorted out.
    Diane123456 wrote:
    > Thanks Vix, Joe, and Mad Dog for responding, the site is
    in
    > development so it's behind a password, which I probably
    could share
    > but MD is right, it was a margin issue. I didn't think I
    needed to
    > set a margin but I had to put a left margin of 2em on it
    for the
    > numbers to display on IE7 or IE6
    >
    > This is actually a rather common issue with CSS layouts
    (it is not an
    > issue with designs using tables) - there are several
    posts for ULs
    > which you may be interested in - see
    >
    >
    http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=
    > 1981&productId=1&loc=en_US
    >
    > -- and once I got the numbers to show I ran into the
    same problem as
    > the commenters on the above thread, which noticed that
    the vertical
    > alignment doesn't work well with IE, and which noted
    that apparently
    > IE has a stutter because it just kept repeating "1" "1"
    "1" -- so I
    > finally went with a hanging indent and just put the
    numbers in there
    > manually - fortunately it's not a long list.... if you
    have a fix
    > for the stutter, or know of another place to get help
    with CSS layout
    > browser quirks please share -- if I find another one
    I'll share also
    >
    > thanks again, Diane

  • There is no way to see who is on line when using facebook with iPad 2

    There is no way to see who is on line when using facebook with iPad 2 why is that?

    I'm guessing you mean for FB Chat? Try the app Friendly.

  • When using Numbers with iCloud, a new version of the spreadsheet is created even when no reisions have been made. Why is this, and how do I make it stop?

    When using Numbers with iCloud, a new version is created every time I make a change. I do not want all these revised documents. When I change a document, I commit to that change. How do I shut off this multiple-revision feature of Numbers being pushed to iCloud.
    Also....
    When using Numbers with iCloud, a new version of the spreadsheet is created even when no revisions have been made. Why is this, and how do I make it stop?
    My files are growing.

    Your plugins list shows outdated plugin(s) with known security and stability risks.
    # Java Plug-in 1.5.0_11 for Netscape Navigator (DLL Helper)
    # Adobe Shockwave for Director Netscape plug-in, version 11.0
    Update the [[Java]] and [[Shockwave|Shockwave for Director]] plugin to the latest version.
    See
    http://java.sun.com/javase/downloads/index.jsp#jdk (you need JRE)
    http://www.adobe.com/shockwave/welcome/

  • When using pdfFactory with Firefox, why are the colors on the pdf not correct?

    The colors are vastly different when using pdf Factory with Firefox. When using pdfFactory with IE, they are both the same.

    There doesn't seem to be a one-size-fits-all answer, because what works for one printer doesn't necessarily work for another, and I don't have your printer so I can't advise on specifics...
    However, perhaps we can discover a set of settings that will work...
    If you File - Print, choose Photoshop Manages Colors, in the Printer Profile section do you see profiles specific to your printer (e.g., with the name Kodak in them)?
    If so, choose one of them that seems appropriate given the paper you're using.
    If not, try choosing sRGB IEC61966-2.1.
    Now, before you continue, press the [Print Settings...] button.  This brings up the printer driver dialog.  You may have to go through [Advanced] buttons or whatever, but what you're looking to do here is to disable the printer driver's color management logic.  In other words, if you can find a color-management / ICC profile handling section, set it to "no color management" or equivalent.  OK back out to Photoshop's print dialog, then press [Print].
    The key here is that if Photoshop manages the color transforms, the printer driver should not be set to do so - or vice versa.
    If you're presented with the printer driver's dialog again, double check that the settings you chose above are still set, for good measure, and try a test print.
    -Noel

  • Is there a flash when using the camera on the iPad?

    Is there a flash when using the camera on the iPad?

    Unlike iPhone, there's no LED flash on iPad. But iPad's specs indicate that it does have a backside illumination sensor to increase the amount of light captured and thereby improve low-light performance. Apple say:
    "The 5‑megapixel iSight camera features a backside illumination sensor that captures great-looking pictures whether by sunlight or candlelight." (Source)

  • Why is there no chime when my macbook re-starts?

    why is there no chime when my macbook re-starts?

    Jim Baggins,
    perhaps because it was somehow set to not chime?
    Try opening Terminal, and run the following command in the Terminal window:
    nvram SystemAudioVolume
    What output does this command generate?

  • Is there a way that when using airplay with power point the ATV does not sleep/screen saver frequently

    s there a way that when using airplay with power point the ATV does not sleep/screen saver frequently???

    I have done this for several Titles, using Photoshop and a Layer Mask, that gets "erased," revealing the letters. My Titles were of "handwriting with chalk" on a blackboard, so I could keep the edge of that Layer Mask, looking more like the "chalk." Photoshop also makes it easy to output Layer Comps for each "step" in the handwriting process. IIRC, I did about 5 Frames per Layer Comp on Import, but do not recall if I used an extremely short Cross-Dissolve Transition between those - I intened to do so, but just do not remember if I liked that, or went with just the Still Images? Will try to find that animation, and maybe create a full tutorial of the process. In my case, I also added an SFX of chalk on a chalkboard.
    If you have Photoshop, it's really quite easy to pull off.
    Now, I do not know if Photoshop Elements has Layer Masks yet, which make it so very easy to accomplish. One could do it backward, where the Text Layer gets Erased, and then one would have their full Image as the last in the sequence, and then the next would have a little bit of the Text removed, then a bit more, then a bit more - going backward, until the "writing surface" is clean. One could also do this with a Transparent Background, so that one saw the Video below, and no actual "writing surface" visible.
    Good luck,
    Hunt

  • Why does iMovie abruptly abort when using record voice over?

    Why does iMovie abruptly abort when using record voice over?

    Hey PTD1,
    Thanks for the question. If I understand correctly, iMovie unexpectedly quits when using record voiceover. I would recommend that you read this article, it may be able to help the issue.
    iMovie: How to troubleshoot "Application Unexpectedly Quit" messages - Apple Support
    Thanks for using Apple Support Communities.
    Have a great day,
    Mario

  • HT3310 Why can't I hear when using my ear plugs on my I-pad

    WHy can't I hear when using my apple ear phones on my I-pad?

    Make sure that they are inserted all the way into the jack. It takes a firm push to insert them all the way.

  • Is there a way when using iTunes Visualiser, I can put the lyrics on screen?

    Is there a way when using iTunes Visualizer, I can put the lyrics of the song i am playing on screen? It would be really cool.

    I got it to work now by writing code to convert it back to an array. Thanks

  • Best practice when using Tangosol with an app server

    Hi,
    I'm wondering what is the best practice when using Tangosol with an app server (Websphere 6.1 in this case). I've been able to set it up using the resource adapter, tried using distributed transactions and it appears to work as expected - I've also been able to see cache data from another app server instance.
    However, it appears that cache data vanishes after a while. I've not yet been able to put my finger on when, but garbage collection is a possibility I've come to suspect.
    Data in the cache survives the removal of the EJB, but somewhere later down the line it appear to vanish. I'm not aware of any expiry settings for the cache that would explain this (to the best of my understanding the default is "no expiry"), so GC came to mind. Would this be the explanation?
    If that would be the explanation, what would be a better way to keep the cache from being subject to GC - to have a "startup class" in the app server that holds on to the cache object, or would there be other ways? Currently the EJB calls getCacheAdapter, so I guess Bad Things may happen when the EJB is removed...
    Best regards,
    /Per

    Hi Gene,
    I found the configuration file embedded in coherence.jar. Am I supposed to replace it and re-package coherence.jar?
    If I put it elsewhere (in the "classpath") - is there a way I can be sure that it has been found by Coherence (like a message in the standard output stream)? My experience with Websphere is that "classpath" is a rather ...vague concept, we use the J2CA adapter which most probably has a different class loader than the EAR that contains the EJB, and I would rather avoid to do a lot of trial/error corrections to a file just to find that it's not actually been used.
    Anyway, at this stage my tests are still focused on distributed transactions/2PC/commit/rollback/recovery, and we're nowhere near 10,000 objects. As a matter of fact, we haven't had more than 1024 objects in these app servers. In the typical scenario where I've seen objects "fade away", there has been only one or two objects in the test data. And they both disappear...
    Still confused,
    /Per

  • When using iPhone with Ford automobiles' Sync, the connection drops each time the ignition is shut off. In order to restore, the bluetooth must be turned off on the iphone, then restarted. Any suggestions?

    When using iPhone with Ford Automobiles' SYNC, the connection drops each time the ignition is shut off. To restore, you must turn off the bluetooth on iPhone, then restart each time. Any suggestions?

    There is an update avaialbe for Ford systems to correct bluetooth problems. You need to update your system.

Maybe you are looking for

  • JDBC Driver not found when connecting to Data Federator XI 3.0 SP3

    Hello, I am trying to connect Crystal 2008 to Data Federator however I am getting the Error Failed to open connection. Details: JDBC Driver not found. The JDBC Drivers are installed and working for the Universe Designer, however I am unable to get it

  • IPhone screenshot quality is low when capturing images. Why ?

    I took screenshots in iPhone5 and the Quality of the PNG screenshots is low. This happens only when we are capturing a screenshot in the iPhone which has image in it's screen... If the the screenshot has GUI of an App, it has 100% Quality in the scre

  • FRM-40735 when validate-item_trigger raised unhandled exception ORA 06502

    Hi, after i migrated my form to 10g when I enter a new record into the form and want to save I get the following message: Frm-40735 when validate-item_trigger raised unhandled exception ORA 06502 what could be the reason? It worked before in 6i but n

  • Bug in deploying in exploded format

              when i deploy my whole application in exploded format..the welcome page is not           picking up from the web.xml file.is it a bug? if anybody knows,i would be appreciated           if you reply me soon           thanks           Seri   

  • Can longer view Theatrical Trailers after upgrading to FR 1.3

    Got a new Mac Mini and was playing with FR and everything was fine. Ran the software update utility, which installed an upgrade to FR, but now all the theatrical trailers just hang with a black screen. I can see the movie jackets, but no matter which