Skip to main content
Known Participant
April 23, 2019
Answered

Change one date format to another.

  • April 23, 2019
  • 2 replies
  • 1665 views

In the date1 field, I have a date in ddmmyyyy format. In the date2 field, I want to display a date from the date1 field in the d. m. yyyy format. How to do it?

This topic has been closed for replies.
Correct answer try67

You can use this code as the custom calculation script of "date2":

var s1 = this.getField("date1").valueAsString;

if (s1=="") event.value = "";

else {

    var d1 = util.scand("ddmmyyyy", s1);

    event.value = util.printd("d.m.yyyy", d1);

}

2 replies

Known Participant
April 23, 2019

Super! It works perfectly!

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 23, 2019

You can use this code as the custom calculation script of "date2":

var s1 = this.getField("date1").valueAsString;

if (s1=="") event.value = "";

else {

    var d1 = util.scand("ddmmyyyy", s1);

    event.value = util.printd("d.m.yyyy", d1);

}

Participant
October 31, 2020

Oh my goodness, brilliant. Thanks so much.