Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Hi,

I'm using a create service to add a record from input objects and a datepicker. When I don't include the datepicker, the records are added without issue. When I try to map the datepicker to the date column, no record is added.

I thought it might have to do with the date format so i created a simple javascript in the mapping to test.

return('2014-11-29 00:00:00.000') //This works

How do I change the date format of the date picker to make the datebase happy?

return $.datepicker.formatDate('yy-mm-dd', '2014-11-29 00:00:00.000'); //This doesn't work :(

//return $.datepicker.formatDate('yyyy-mm-dd', value); //what is the correct syntax?

I've added some screen shots to assist.

Thanks for your help.

Gabriel

Image Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Hi Gabriel,

Add this JS code in datepicker and request parameter mapping: pred = new Date(value);
return d.toISOString().replace("T"," ").replace("Z","");/pre

Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Hi,

Thanks for the response. I added it to the mapping but don't understand what you mean by adding it to the datepicker. Can you add JS to a component?

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Hi Gabriel.
"add it to the mapping" - I think that's what Katya wanted to say

Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

In that case, it doesn't work :( No record is added. If I take out the mapping for the date it adds a record, but with the date it does not.

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Correct format is 'yyyy-mm-dd'.
You should change Date Format in Datepicker component properties to
yy-mm-dd
OR if you want date to look like 21/12/2013 you should change js code in mapping with
precodevar parts = value.split("/");
return parts[2] + "-" +parts[1] + "-" +parts[0];/code/pre

Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

That worked! I used the js code in the mapping.

Thank you :)

Alyssa Rolfe
Posts: 0
Joined: Fri Jun 20, 2014 12:48 pm

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

If I do not want the date picker to record the time in the DB, how would I go about doing this? I do not want it displayed when I list the data from the DB.

Should I change the way that it is recorded into the database or the way that it later reported?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Hello Alyssa ,

If you store a date in the column of type date, then format of this data type stores date and time. So if you don't need time, you need to remove this part of the data when the data is displaying on the page.

Alyssa Rolfe
Posts: 0
Joined: Fri Jun 20, 2014 12:48 pm

DatePicker date will not add to a database. How do I format datepicker date to make the DB happy?

Is there a way to code for the removal of the data or to overwrite it with blank spaces?

Would I add this to the mapping? I am very new to this an very slowly working my through it.

Return to “Issues”