Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Auto-fill from Date Field to Text Field in YYMMDD Format

Avatar

Level 2

Hello,

I need to auto-fill a text field with a date that is entered into a date field. I was able to accomplish this, but I couldn't figure out how to have it formatted in the text field as YYMMDD (with no spaces, dashes, etc.) instead of "MM/DD/YY" as it is displayed in the date field.

Could someone help me with the proper code?

Best Regards,

ZeroZone110

1 Accepted Solution

Avatar

Correct answer by
Level 10

I dont know if it's the best option, but here's a workaround...

using formcalc you can format your date fields

var myDate = Date2Num(DateField1.rawValue, "YYYY-MM-DD")

var formatDate = Num2Date(myDate, "YYYY-MM-DD")

TextField2.rawValue = formatDate

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

I dont know if it's the best option, but here's a workaround...

using formcalc you can format your date fields

var myDate = Date2Num(DateField1.rawValue, "YYYY-MM-DD")

var formatDate = Num2Date(myDate, "YYYY-MM-DD")

TextField2.rawValue = formatDate