Datetime vs date only

As you might guess, I am new to Appgyver. (By the way, so far I like it alot!)

I have a firebase collection with a date configured as a “timestamp”. I display the data in a “basic list” component. It shows the date and time. I am not interested in the time. I don’t want that to be displayed (it is meaningless in my app). How do I get the basic list to display just the date?

FYI, at first I configured the date field in firebase as a string. Therefore, my data variable date field in Appgyver was also configured as a string. But when I tried to bind my date data variable to the date picker component, I was met with the dreaded “incompatible” notice - something about an inability to convert a date-time object to a string. I tried creating a function to do that conversion, “STRING(data.myData.date)” but Appgyver rejected that as well. I also tried the SPLIT() function, but that did not work either (I’m not entirely sure why Appgyver rejected that).

So, I reconfigured the date field of my data variable to a date type (not a date-time type) but that has not solved the problem. My basic list is displaying date-time, not just date.

(I am trying to do what appears to be somewhat difficult in Appgyver, namely, display existing data (in the date picker) but also permit it to be changed. I’ve previously struggled with an input field both showing existing data and allowing a change to that data - and had only moderate success. I’ve seen other people on the forums struggling with that as well. I assume I’ll figure it out as I become more familiar with Appgyver.

At any rate, any assistance in solving my date-time issue will be appreciated.

I guess Your solution should be the

FORMAT_DATETIME_LOCAL(data.yourDate, "YYYY-MM-DD")

This would only show the described format. Use these placeholders to arrange as you please:

YYYY - full year
YY - last two digits of the year
MM - number of the month
MMM - short of the month e.g. Jun
MMMM - full written text of month e.g. June or December
DD - number of the day

In case You do want to format your time as well you can have these (among others):
HH - hours
mm - minutes
ss - seconds
ms - milliseconds

Hope this helps. Also, feel free to check out the documentation here, there are a ton of useful formulas:

I have used the FORMAT_DATETIME_LOCAL(data.yourDate, “YYYY-MM-DD”) to display a date from a backend. The backend shows the correct date all the time, but during certain hours of the day, the text fields show the complete wrong date!! It’s like from 7pm - 10pm and 7am - 10am Central Time. Do you have any idea why?? I am going to make a post about it later tonight if you don’t have a quick answer. FYI, I use @Mevi calendar component to pick the date.

@Trent_DeLoach
What backend do you use?
What is the value that is received by Appgyver from the backend?
I mean what is the raw value of the “data.yourDate” before the formula?

Where do you want to use this formula exactly?

And I am not sure how would this formula ever show anything in connection to hours and minutes. You set the formula to only show the year-month-day and in the problem description you talk about hours in the central time, I am unsure what your problem is…

@Mihaly_Toth I guess I should state this differently. It is when selecting the date in the app for the first time, before it even gets to the backend. I have it reading it from the backend (Xano) correctly. So here are some screenshots to attempt to show you what I am dealing with.

So with this first set, this is after 6pm Central time. We are selecting the 8th on the calendar to set a page variable of dateChambered (Date text (ISO 8601) The first text box in light purple (Date Chambered:) is set to show the page variable with this formula:

FORMAT_DATETIME_LOCAL(pageVars.date_chambered, “MM-DD-YYYY”)

As you can see in the screen shot, it has entered the wrong date (The previous day)

The 2nd box in red is reading the page variable as it is set, no format. It is the correct date, but UTC time.

The 3rd box in yellow is if you use this formula:

FORMAT_DATETIME_LOCAL(ADD_DURATION(pageVars.date_chambered, 1, “days”), “MM-DD-YYYY”)

image

So you would think, great, just use the last formula because it give you the correct date right? Well, no, because as soon as you hit 12:00am Central time, you get the correct date in the first box, but the formula to add a day is wrong. (See next screen shot)

image

As stated before, the date is only wrong using format_datetime_local from 6pm to 11:59 central.

When submit button is hit, XANO gets the raw page variable sent to it, and the date is ALWAYS right, no matter what the time. It trips me up.

Thanks for the detailed description. Let me suggest then the followings:
Utilise the below formula instead of the FORMAT_DATETIME_LOCAL()

FORMAT_DATETIME_WITH_TIMEZONE(date: String, format: String, timezone: String) => String

Read more on these formulas here:
https://docs.appgyver.com/docs/format-datetime-with-timezone?highlight=format%20date

https://docs.appgyver.com/docs/format-datetime-local

In case there is still something weird happening you may even go further and try this, with your variables:

FORMAT_DATETIME_WITH_TIMEZONE(pageVars.date_chambered, "MM-DD-YYYY", LOCAL_TIMEZONE())

To me it seems that there might be some issue with the way how the device detects the local timezone. You could even try to print the LOCAL_TIMEZONE() value to the screen to check if your device thinks of the same timezone as you do. If not then that is the issue, if yes, please report back here.

Read more on LOCAL_TIMEZONE() here:
https://docs.appgyver.com/docs/local-timezone

Hope this helps,
Cheers,
Mihály :koala:

@Mihaly_Toth,
Unfortunately neither of those fixed it. As you can see in this screenshot, it is kicking it back to the 7th again, at 6:59pm Central. The device is seeing the correct time zone. It is something to do with the dang Format_DateTime_Local that is breaking it, even if you use the _Timezone on the end.

image

Just an update… this formula set seems to have fixed it:

GET_DATETIME_COMPONENT(pageVars.date_chambered, “month”) + “/” + GET_DATETIME_COMPONENT(pageVars.date_chambered, “date”) + “/” + GET_DATETIME_COMPONENT(pageVars.date_chambered, “year”)

image

Sorry to hear that I couldn’t be much help, but I am glad that you’ve figured this out. Hope you’ll sort out all the other issues you may encounter.