Expand my Community achievements bar.

Date/Time formatting


Former Community Member
I know this topic has been hashed and rehashed, but I am looking for example as to how to combine date and time in same field:

e.g. I have date/time field. I set binding to 'Date and Time'. Validation is 'date{MM/DD/YYYY} time{HH:MM}'

So far so good. However, I cannot set the right Display or Edit Pattern. In my 'calculate', I have:

var today = new Date();

var month = today.getMonth()+1;

var day = today.getDate();

var year = today.getFullYear();

var hour = today.getHours();

var minute = today.getMinutes();

this.rawValue = (month < 10 ? "0" : "") + month + "/" + (day < 10 ? "0" : "") + day + "/" + year + " " + hour + ":" + minute;

I want to have format as MM/DD/YYYY HH:MM. If I put that into Display Pattern, it complains about invalid pattern, it accepts 'date{MM/DD/YYYY} time{HH:MM}'. But then displays nothing in the Preview.
4 Replies


Former Community Member
probably a stupid way to do it but it might do what you want.

Javascript on a regular text field:

this.rawValue = util.printd("mm/dd/yyyy",new Date()) + ' ' + util.printd("HH:MM",new Date());


Former Community Member
Well, if I change to Textfield, everything displays, but now the validation no longer works, and it does not actually accept any changes when I tab out.


Level 7
Have you set the "Date Format" on the "Binding" tab, the "Display Pattern" on the "Field" tab and the "Validation Pattern" on the "Value" tab?

All of these fields need to match or be of a compatible pattern.


Former Community Member
Here is how I achieved it:

Create a textfield, data format is plain text, type is 'Calculated, user can override'. In 'Calculated' event, place string to set rawValue, e.g. MM/DD/YY hh:mm. In 'Exit' event, parse the date, and the time separately, and check the format manually.