Page 1 of 6

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

Posted: Tue Dec 24, 2013 7:57 am
by Gabriel Bizcarra

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


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

Posted: Tue Dec 24, 2013 10:19 am
by Kateryna Grynko

Hi Gabriel,

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


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

Posted: Tue Dec 31, 2013 7:59 am
by Gabriel Bizcarra

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?


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

Posted: Tue Dec 31, 2013 8:59 am
by Oleg Danchenkov

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


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

Posted: Wed Jan 01, 2014 10:52 pm
by Gabriel Bizcarra

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.


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

Posted: Thu Jan 02, 2014 10:51 am
by Oleg Danchenkov

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


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

Posted: Thu Jan 02, 2014 1:47 pm
by Gabriel Bizcarra

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

Thank you :)


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

Posted: Fri Jun 20, 2014 12:48 pm
by Alyssa Rolfe

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?


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

Posted: Fri Jun 20, 2014 1:58 pm
by Evgene Karachevtsev

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.


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

Posted: Fri Jun 20, 2014 2:21 pm
by Alyssa Rolfe

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.