Date format issue

Shilpa Kamath
Tera Contributor

Hi,

 

I am trying to achieve number of days difference between a date variable (end Date) and current date. The date variable on the form is auto populated through onchange client script and it returns the date in the format yyyy-mm-dd which is fine, but then when i change the date, the date is saved in the format dd/mm/yyyy. Since the system returns the current date in yyyy-mm-dd format, finding it hard to subtract the dates which are in 2 different formats.

Is it possible to convert the date format from dd/mm/yyyy to yyyy-mm-dd or vice verse  for the calculation to work?

 

1 REPLY 1

Mike Patel
Tera Sage

Not sure about your code but you can do something like below to get date in format you want

 

var date= new GlideDate();//replace new GlideDate() with the incoming date
var date2 = date.getByFormat('yyyy/MM/dd');//now use the date2 to set the field value