More weird dates

Hi All

Having another weird date problem on Xojo Cloud.

I am setting two dates ‘from’ and ‘to’. The ‘from date’ is working fine, but the following code to get the ‘to date’ does not work on Xojo Cloud, it works fine running locally however.

dim mdOneDay As New DateInterval
mdOneDay.Days = 1
msDateValueTo = Str(d.Year) + “-” + Str(d.Month + 1) + “-01 24:00”
dim pdToDate As Date = Date.FromText(msDateValueTo.ToText)
dim mdMonthEnd As Date = pdToDate - mdOneDay

Any clues as to what’s going on?

Thanks Chris

Perhaps you should try something like:

Dim d As Xojo.Core.Date = xojo.core.date.Now Dim d2 As New Xojo.Core.Date(d.Year, d.Month+1, 2, Xojo.Core.TimeZone.Current) dim di as new xojo.Core.DateInterval(0,0,1) dim d3 as xojo.Core.Date = d2-di

You are setting time to 24:00 that ist the same like "Str(d.Year) + “-” + Str(d.Month + 1) + “-02 00:00”
As you didn’t mentioned what problem you have in Xojo Cloud. I can’t tell you anything else…
For me, that code does exactly, what yours should do…

Sorry everyone I must not been thinking.

The problem is that on the Xojo Cloud the code I am using is not taking a day off is it does when I run it from the desktop.

The to date are the get all transaction records from the being of the day ‘from date’ to the end of the day ‘to date’. which is why I am setting the time to 24:00.

Use 23:59:59 instead

Thanks Greg

Who would of thought that 24:00 is tomorrow & 23:59:59 is today.
But can you tell me why?

Because when you add 24 hours to any time it is tomorrow (unless you’re on Mars).

[quote=312511:@Chris Percival]Thanks Greg

Who would of thought that 24:00 is tomorrow & 23:59:59 is today.
But can you tell me why?[/quote]
Because the first full hour of the day is 0, not 1. This is standard military time (at least in the U.S.), but they still wanted hours 1-12 to be the same as civilian time. That way they can just subtract 12 from the afternoon hours and get civilian time.