Subtraction by one day - Date Bug

Hey All!

I am having an issue with displaying the correct date in a text component. I am trying to display, with magic text, the Date of a scheduled meeting. For example: I stored the Date “7/21/22” by inputting it into this form:

The same date is being displayed next to “Date:” in the screenshot below:

Screen Shot 2022-07-19 at 3.35.47 PM

As you can see, the date has changed to “7/20/22”.

For more proof, I did this same thing by inputting “7/20/22” into the form and the text box displays that value as “7/19/22”. What is clearly happening here is some kind of subtraction by one day.

The only thing I am changing in between storing and displaying this value is the object that the date belongs to. The date gets stored in my “Available Days” Collection, but by the time I display it, it is in the “Meetings” collection. All I am doing is transferring the date from one collection to another, and somehow it is getting subtracted by one.

Why is this happening and how can I fix it?

Thanks!

Hi @knuggie,

The dates are stored on a collection inside Adalo right? Maybe it’s due to the timezone? ( I guess it should be no )

Is it possible to share a video of this behaviour including the device time too?

Thank you

Hi @dilon_perera , here are two videos describing my problem.

(ReEdited) Adalo Date Bug Pt. 1

In the first video (above) you can see I am creating a new “Available Day” object via a form. As you can see, the day I am choosing is July 24th, 2022.

(ReEdited) Adalo Date Bug Pt. 2

In the second video (above), I am now logged in as a different type of User. I click on John’s availability screen and can now see a new day of availability (the one that we just added via the form). I select and confirm a time. However, back on my upcoming meetings list, the meeting is incorrectly displaying as being on July 23rd, NOT July 24th (as it should be).

Even when I look in my Meetings Collection, I can see that it stored as the 23rd (as shown above)

Why is this happening? Today’s date is July 22nd (of recording these videos).

Thanks!

Is there a update action on the times in the Mentor Availability screen that updates this date? ( if not click actions maybe as a screen action )

Hi @dilon_perera - see image below

Every time slot has its own orange confirm button, and every orange confirm button has a Create Meeting action that fills with the data in the image above. Within the Meeting’s fields, the “Meeting Day” field specifically gets filled with the current Available Day’s “Date” field. (Where I am making sure to use MM/DD/YYYY format). The current Available Day’s “Date” field is actually being displayed at the top of each day on this screen, so we know exactly what the correct date should be when it gets stored in the Meeting object in the orange confirm button. However the correct date is not being stored - it always stores the date that is exactly one day before the correct date.

Apart from this simple moving from one object to another, (again - the Current Available Day’s Date field getting stored inside a New Meeting’s Meeting Day field) no other manipulations are happening to either of these fields.

This is why I’m not sure what’s exactly going on here.

Thanks for the help, Dilon. Much appreciated!

Hi @knuggie,

This is a date transfer bug, which is related to the way Adalo works with dates. I’ve reproduced it in my test app - same effect.
I think the reason is the following.

To start with, Adalo internally stores DateTimes and Dates as number of days since 1/1/1970. For DateTime, Integer value represents the date, and decimal represent the “fraction of the day”.
E.g. 19196.25 is equal to 6AM, 23rd of July 2022 in GMT+0 time zone. Then, the actual time displayed for a user is adjusted using user’s timezone settings. For someone in New York (GMT-4) this date will be displayed as 2AM same day (though, of course, the value stored doesn’t change).
For Dates, only Integer value is stored in the database (e.g. 19196 for 23rd of July 2022).

I guess in your case the following happens. When you update the date property in the first collection, it is stored correctly (as 19196 for today).
But when you update the date property in the second collection with the date from the first one, here is what might happen:

  • Adalo takes the date as “date” (e.g. 19196)
  • then it adjusts it to your timezone (prepares it to display as 8PM 22nd of July)
  • and when it stores it to the second collection, it does another conversion from Datetime to date (8PM 22nd of July → 22nd of July = 19195).

This bug will exist for the countries with timezones to the west of Greenwich.

What could be done here:

  • store dates in datetime format (potential issues for the users from very different timezones)
  • use numeric property to store the date’s value “in between”.

Hope this was useful.

Best,
Victor.

1 Like

Thanks Victor for this great explanation! Appreciated!

1 Like

Hi @Victor ,

I appreciate your explanation! So I think I understand what you’re saying and why this bug may be occurring.

For your suggestion - when I first get the Date from the User in that form above, I should use the “Date & Time” type, and not just “Date”.

This one right?

Thanks.

Changing to DateTime fixed it!

Thanks @dilon_perera and @Victor !!

2 Likes