I have a form with a Datepicker field and a DB field of type DATE. I am not able to store any date type or numeric type into the database. A string field just stores OK. What should be done to get those data stored also?😶
Forums
How to save Datepicker data into DB
Hi hoekbrwr,
If your form is submitting a date in a string format that MySQL will recognise it should save OK as a type date, What is being submitted now?
Bob
If your form is submitting a date in a string format that MySQL will recognise it should save OK as a type date, What is being submitted now?
Bob
I just click the Datepicker graphic and leave it untouched further. It is in the format d-m-Y format as defined in the settings.
Hi hoekbrwr,
And MySQL won't recognise that as a DATE . . . so either you need to change the format in the datepicker, or use a Custom Code action to convert the string after the form is submitted but before the data is saved.
There's more in the MySQL manual here.
Bob
And MySQL won't recognise that as a DATE . . . so either you need to change the format in the datepicker, or use a Custom Code action to convert the string after the form is submitted but before the data is saved.
There's more in the MySQL manual here.
Bob
When I use the mask setting Integer for a supposedly integer input field I see a change in my input field. It is now right adjusted signing a numeric value to use. However I cannot input any number!
Hi hoekbrwr,
Please post a different topic in a new thread. so far ChronoForums won't let me split threads :-(
Bob
Please post a different topic in a new thread. so far ChronoForums won't let me split threads :-(
Bob
This is not so user friendly! If you use a Datepicker Box you have to use extra code to get that element functioning. This means for every format you need to have a Custom code. It should have been integrated with the Datepicker Box code. Only few people are fluent in using Custom code and I am not one of them! It is not an option to show another format as usual in my country, different from the database format.
Hi hoekbrwr,
True, it could be better, maybe that will get fixed in a future version. I don't remember anyone else asking this question so it probably isn't high on Max's list though.
Please see this StackOverFlow answer for an example of the code you need.
Bob
True, it could be better, maybe that will get fixed in a future version. I don't remember anyone else asking this question so it probably isn't high on Max's list though.
Please see this StackOverFlow answer for an example of the code you need.
Bob
Hi hoekbrwr,
And MySQL won't recognise that as a DATE . . . so either you need to change the format in the datepicker, or use a Custom Code action to convert the string after the form is submitted but before the data is saved.
There's more in the MySQL manual here.
Bob
The only format in Chronoforms which MySQL understands is YYYmmDD or alike. That is not an option for my country!
Hi,
The format which mySQL understands is Y-m-d, which is not suitable in all situations, but that's how it is, and if you want to save your form date in this format then you must place the code to do this, for most common formats, you can use the strtotime function:
Regards,
Max
The format which mySQL understands is Y-m-d, which is not suitable in all situations, but that's how it is, and if you want to save your form date in this format then you must place the code to do this, for most common formats, you can use the strtotime function:
$form->data["date"] = date("Y-m-d", strtotime($form->data["date"]));
Regards,
Max
because its dependent on the date field name and format, this is very ambiguous to account for!
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.