Date Formatting for Date Picker

OS info

Problem description

Datepicker prevents dates stored in the databse from showing in update form, and if selct todays date in the second date field in the form no value is added too the field. If I select tomorrows date, and clik the field again I’m allowed to select todays date… strange

Steps to reproduce

  1. Go to : https://tw60.transportsystemerjohnnysolberg-321a.websitebuilder.no/tur_update.aspx?ordreid=760986&turid=448832
  2. Both Hentedato and Leveringsdato fields are empty. The values are in the database
  3. Click field “Hentedato” (Pickup date in Norwegian) Select todays date. No problem
  4. Click field “Leveringsdato” (Delivery date in Norwegian) Select todays date. No value. Select tomorrows date. No problem. Click field again, select todays date. No problem

Your dates in the database are stored as strings and not in a valid ISO format. You can’t store dates like that, they must be stored in a date filed in your database, in the format required by your database not as strings.

1 Like

They are stored as ISO in the database, they are just formatted as norwegian dates on output. And if I save them as 31.12.2019 they will still be stored as ISO dates. Thats not what couses the problem here. In the insert form are the dates also inserted as 31.12.2019 without problems. I can get them to show without problems if I remove Datepicker, but then again I can not let the users add the dates manually. It is the same problem with setting the field as a date field, it will not show the saved dates either but this is a known problem in HTML5 for european dates, the value= has to be in US date format YYMMDD. That doesnt work for us in Norway, as the dates will be misunderstood by the users as the norwegian dates are ddmmyyyy.

What do you mean on output? I see your server action returning the dates from your database in a wrong format (non ISO formaT)

This is not a known issue and this is not an US date format, and this is not really related to HTML5… The default date format depends on your database.

In your database you should not store the dates like this format (dd.mm.yyyy). They must be stored in a DATE field, formatted as your database DATE field format requires. In most databases, this is something like yyyy-mm-dd.
Then on your pages, using the data formatter (or as in your case it is - the calendar) you can format the dates however you like.
What database are you currently using? And what database field type?

I’m using MSSQL 2016, and the data is stored in the database in the format yyyy-mm-dd hh.mm.ss
In my database query i change the format using Convert(varchar;fieldname;104) so the output is in Norwegian format.

If you look at the two screenshots in this post, you will se what I mean by date fields only accept what I call US dates (YYYY-MM-DD). I made a new output value called DatoL in this format and the this happpens:

Standard texfield with datepicker : showing value OK
Standard date field : Showing OK
Standard datefield using wappler field : Not working with dmx-bind:value=“Query_dataconnect.data.Tur_valgt[0].DatoL” or value="{DatoL}"
Standard textfield: showing iso value OKscreen11

You should not be doing this, don’t change anything for the query. The date must be passed on the page as it is. In the calendar options you can use your own format, so that the date will be displayed on the page in your desired format.

I see that now, I am used to Dreamviever where there where no format options like that. Problem solved in Wappler as always.
But I still have that strange bug refusing med to select todays date in the datepicker calendar. It work in the the date field calendar :slight_smile:

https://tw60.transportsystemerjohnnysolberg-321a.websitebuilder.no/tur_update.aspx?ordreid=760986&turid=448832&bilid=

I am not sure i understand that. Can you explain what are you doing there exactly?

If you take away the value in the Leveringsdato datepicker field, and try to select todays date from the calendar that pops up, the input field stays blank. If you select tomorrow first, you can change it till todays date. Not a big problem, but one sure to get me some calls from users

It only happens if the field is empty. Strange

That seems to happen with any date which is selected, if you delete the value and try to re-select it, it stays blank. The question is - why would you delete the value of the input at first place? :slight_smile:
We are going to investigate this.

1 Like

Sorry, bad explanation. In an insert form, the date fields will be blank