Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

How can I define a variable which would be the Date column on the database? I want it to split the value in the database so I need a variable

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

Hi Ellen,

pre

var dateText = "23/10/2003";

var date = new Date(dateText);

var dateFormat = date.toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

alert(dateFormat);

return dateFormat;

/pre

Regards.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

So I would put that code in the JS for the label component where I want it displayed (same as before) then paste the code from earlier too?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

Hi Ellen,

It's very depends on your needs what you need to do.

Regards.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

I want to reorder the date and get rid of the time. I could use this code to do that but I need some sort of variable to link back to the database. It would replace value.

var yyyymmdd = value.split(" ")[0].split("-");
return yyyymmdd[1] + "-" + yyyymmdd[2] + "-" +yyyymmdd[0];

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

Hi Ellen,

To store in DB you should add following JS code to "Date" type request parameter:

pre

var dateText = "23/10/2003";

var date = new Date(dateText);

var dateFormat = date.toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

alert(dateFormat);

return dateFormat;

/pre

This code will return date in correct for REST API format.

Also you can modify this code to give more dynamic logic.

Regards.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

So should that be on the listing end or the creating end of things? I am not familiar with what correct REST API format is so is that yyyy-mm-dd 00:00:00 or would it be mm-dd-yyyy?

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

So if I put my code at the end of it, dataFormat world replace value right?

var dateText = "23/10/2003";

var date = new Date(dateText);

var dateFormat = date.toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

alert(dateFormat);

return dateFormat;

var yyyymmdd = value.split(" ")[0].split("-");
return yyyymmdd[1] + "-" + yyyymmdd[2] + "-" +yyyymmdd[0];

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

Hi Ellen,

Not sure i understand what you want to do. But i see you have two "return" statement. That means your code will run only until first one.

More details here: https://developer.mozilla.org/ru/docs...

Regards

Return to “Issues”