Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
Date arithmetic query |
Mon, Jan 29 2018 7:37 AM | Permanent Link |
StewCam | I am adding 40 weeks to a date called DateSel using the following formula:
DateSel + 280*86400000 However if DateSel is in the previous calendar year and the result is in the current calendar year then the result drops one day. For example, if Date Sel is 31 Dec 2017 then the result is 6 Oct 2018 but if DateSel is 1 Jan 2018 then the result is 8 Oct 2018. What is the most appropriate adjustment to obtain the correct date across the end of year boundary? |
Mon, Jan 29 2018 8:02 AM | Permanent Link |
Matthew Jones | StewCam wrote:
> For example, if Date Sel is 31 Dec 2017 then the result is 6 Oct 2018 but if DateSel is 1 Jan 2018 then the result is 8 Oct 2018. Hmm, are you sure? The Javascript date is pretty straightforward, so I'd want to double check that this is really what you are seeing - that is, do some building of date and make sure the time is right each time etc. -- Matthew Jones |
Mon, Jan 29 2018 8:12 AM | Permanent Link |
StewCam | "Matthew Jones" wrote:
>Hmm, are you sure? The Javascript date is pretty straightforward, so I'd want to double check that this is really what you are seeing - that is, do some building of date and make sure the time is right each time etc. Yes, I can confirm the anomaly. Some additional information is that DateSel is obtained from the calendar: DateSel := StrToDate(Calendar.Text) |
Mon, Jan 29 2018 8:21 AM | Permanent Link |
Matthew Jones | StewCam wrote:
> "Matthew Jones" wrote: > > > Hmm, are you sure? The Javascript date is pretty straightforward, so I'd want to double check that this is really what you are seeing - that is, do some building of date and make sure the time is right each time etc. > > Yes, I can confirm the anomaly. Some additional information is that DateSel is obtained from the calendar: > DateSel := StrToDate(Calendar.Text) Can you put together some code that we can all run to show it. Fixed strings, outputs etc. We can then investigate in detail. -- Matthew Jones |
Mon, Jan 29 2018 8:30 AM | Permanent Link |
Matthew Jones | Also worth mentioning where in the world you are, in case there are time zone changes. I wonder if that is the issue - that would push the addition off by one hour, which could move it into a different day.
When is daylight saving changed this year where you are? -- Matthew Jones |
Mon, Jan 29 2018 8:40 AM | Permanent Link |
Walter Matte Tactical Business Corporation | Whenever I see the 1 day off - it ALWAYS has to do with Date/Time Localization. EWB is fine.
This will resolve your issue: DateSel := StrToDate(Calendar.Text) - (TimeZoneOffset(Now) * 60 * 1000); I also uploaded a helper unit use the MoveDays function https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_binaries&page=1&msg=47#47 function MoveDays(dt : DateTime; iDays : integer) : DateTime; DateSel := MoveDays(DateSel, 280); Walter |
Mon, Jan 29 2018 8:23 PM | Permanent Link |
StewCam | Walter Matte wrote:
>Whenever I see the 1 day off - it ALWAYS has to do with Date/Time Localization. EWB is fine. Thanks very much, Matthew and Walter. Localisation was the issue. I am now using the helper unit, which I see is full of goodies! |
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |