Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Format "date" data type from database

Hi,

I am trying to change the date retrieved from database and format it into "dd/mm/yyyy".
I tried input this ("$.datepicker.formatDate('dd/mm/yy', new Date(value));" and "return $.format.date(value, "dd MMMM, yyyy");" into the js in the mapping, however it does not work.
Is any problem with my coding? How can I accomplish this?

Image

Image

Image

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

Format "date" data type from database

Rui,

Please add next for label_date in the js:
prevar date = value.split(" ");
var date_parts = date.split("-");
return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0]/pre

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Format "date" data type from database

Hi,

I tried to put it in into the js just like what you told me to, but I still get the same result.

Image
Image
Image

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

Format "date" data type from database

Hello,

1) in DB event_date column has correct value
2) Could you add console.log(date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0]);
before return, and open console while testing?
It is looks like you have a cache problem.

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Format "date" data type from database

Hi,

This is the error I get, please advise thanks!

Image

Image

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

Format "date" data type from database

Hi Rui,

".split" functionality return an array.

But you use it like string.

See details here: http://prntscr.com/61nf4c/direct

Regards.

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Format "date" data type from database

Hi,

Thank you so much, I manage to display what I want.
For those who need it, this is a way to achieve it:
"var date = value.split(" ");
var date1 = date[0];
var date_parts = date1.split("-");
return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0];".

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

Format "date" data type from database

Hello Rui,

Thank you for the update, glad it works!

Ilya Nikitin
Posts: 0
Joined: Sun Mar 22, 2015 2:59 am

Format "date" data type from database

Hello.

Thank you for the tips on date formatting.

How to add to beside date time in following format dd/mm/yyyy - hh:mm

Thank you in advance.

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Format "date" data type from database

Hello Ilya,

date[1] - has time frame of datetime.

return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0] + " - " + date[1];

Return to “Issues”