Datepicker returns minus 1 day

Hi guys,

I have this issue, I’m using a date picker (calendar picker) but when I select a date it’s taking the same date minus 1 day.
i.e: If I choose 07/dec/2022 my selected date value is set to 06/dec/2022.

I’ve tried to set a timezone in the SELECTED VALUE property but I get the error: “The binding requires an inversible formula

My formula:
FORMAT_DATETIME_LOCAL(SET_TIMEZONE(DATETIME(appVars.vdate1), “Etc/GMT-4”) , “DD.MM.YYYY”)

Do you have any idea what may be the issue?

Thanks

@Kirill_Leventcov @Vili
A good, useful Christmas :gift: would consist in addressing such question… :slightly_smiling_face:
Sad to see this unattended.

Happy holidays nevertheless…

I saw your bug submit in the tracker.
I get the same issue when my record is a string. I did input 1900 / 02 / 12 but minus 1 was applied to the day.
image

I wish the team could answer with the best practice…

1 Like

The problem may be caused by the time zone you are using. The “Etc/GMT-4” time zone is a UTC-04:00 time zone, which means it is four hours less than Coordinated Universal Time (UTC). If you are in a time zone that is four hours less than UTC, then the selected date will be displayed correctly, but if you are in a time zone that is more than four hours less than UTC, the selected date will be displayed as if it were in the “Etc/GMT-4” time zone, which is one day less.

To fix this problem, you can try setting the correct time zone for your location. To do this, you can use the SET_TIMEZONE function and pass it the time zone for your location as a parameter. For example, if you are in the Santiago, Chile time zone, you can use the “America/Santiago” time zone as follows:

FORMAT_DATETIME_LOCAL(SET_TIMEZONE(DATETIME(appVars.vdate1), “America/Santiago”), “DD.MM.YYYY”)

1 Like

Hi,
Thanks for your response.
I tried before setting local time zone and others time zones but the bug persists.
And btw, my current time zone is GMT-4, I’m in Dominican Republic.

I modified the PICK DATE FLOW to add one day to the date, it’s an unorthodox but it does the trick.

Thanks for this, better this annoying workaround than no solution.
Why does it happen with AG but not with other no code tools?

Anyway, below is a suggestion for you @Haden_Molina if you can’t select the timezone: use NOW()

FORMAT_DATETIME_LOCAL(SET_TIMEZONE(DATETIME(appVars.vdate1), NOW()), “DD.MM.YYYY”)

1 Like

I use NOW() for my default date, but remember that the user can change the date in the calendar.
Anyway, I submitted the bug and the appgyver Team is checking it.

Thanks guys.

I’m using ADD_DURATION(SET_TIMEZONE(appVars.app_DataEvento, LOCAL_TIMEZONE()), 1, “days”)

Additional to that, i’m setting beforehand the hour, minutes and seconds to 00:00:00, thus adding 1 day is more accurate

1 Like

Hi all,

I have now tried looking deeper into this issue. To begin with, I have instructed the “Date picker calendar” component to put the date and time into a page variable that is then displayed next to the Headline. Then after testing on web preview, I get this (It works just fine):

Then, I have tested the Date field and noticed that… although it does output a correct date is subtracts two hours from it:

image

I am fairly sure that this is the issue and what’s causing it to subtract one day. Perhaps timezones with GMT- or UTC- are affected.

2 Likes

Hi! Figured out this was due to the NOW() formula always returning UTC timezone. Used SET_TIMEZONE and LOCAL_TIMEZONE so that there would not be a problem with this and the date would appear correctly. This update will be out in the next release.

2 Likes

:tada:ㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤㅤ⠀ㅤ

Hello Mevis, I tried to use that you inform, but the problem still happing.

@Cristiano_Oliveira hmm I just noticed that for this particular fix to apply, you need to drag a new date field onto the canvas. Please try that.

@Mevi I tried follow what you say, but when I save the date, for example: I choose in the pick date 10.02.2023(Im from Brazil São Paulo) in the backend (Firebase) returns to me 09.02.2023. I tried to use any formulas, for example: SET_TIMEZONE(appVars.app_DataEvento, “America/Sao_Paulo”) or SET_TIMEZONE(appVars.app_DataEvento, LocalTimezone()), and any one save the date that I choose( 10.02.2023)

Hi! Check the output of the date field (without formatting it) – it should come with a timezone attached at the end, -05:00 or something similar for you. Then check if the backend keeps that timezone or if it converts it or drops it somehow.