Hi
in Forms, how to show today's date in a text "Single Line" field, I don't want it in "Date Time" field.
When I mean today's date, it is ok the date the form was opened, so we can use JS.
Thanks
Hi
in Forms, how to show today's date in a text "Single Line" field, I don't want it in "Date Time" field.
When I mean today's date, it is ok the date the form was opened, so we can use JS.
Thanks
These are tested in the Classic Designer on Version 11.0.2212.30907.
Here are some formulas you can put in your Single Line field that will populate the current date.
Formatted as M/D/YYYY:
=MONTH(NOW())&"/"&DAY(NOW())&"/"&YEAR(NOW())
Formatted as YYYY-MM-DD:
=YEAR(NOW())&"-"&RIGHT("00"&MONTH(NOW()),2)&"-"&RIGHT("00"&DAY(NOW()),2)
Formatted as DD/MM/YYYY:
=RIGHT("00"&DAY(NOW()),2)&"/"&RIGHT("00"&MONTH(NOW()),2)&"/"&YEAR(NOW())
Then since you mentioned Javascript, here's some Javascript to do it (again, this is for the Classic Designer). This is based on CSS Class Names dateValue1, dateValue2, and dateValue3 - and are set to update when the form is loaded if the fields are blank to begin with.
$(document).ready(function () { var myDate = new Date(); var m = myDate.getMonth()+1; //one digit month (add 1 because JS defaults months 0-11) var m2 = ("00" + m).slice(-2); //two digit month var d = myDate.getDate(); //one digit day of the month var d2 = ("00" + d).slice(-2); //two digit day of the month var y = myDate.getFullYear(); //4-digit year if($('.dateValue1 input').val() == '') { $('.dateValue1 input').val(m + '/' + d + '/' + y); } if($('.dateValue2 input').val() == '') { $('.dateValue2 input').val(y + '-' + m2 + '-' + d2); } if($('.dateValue3 input').val() == '') { $('.dateValue3 input').val(d2 + '/' + m2 + '/' + y); } });
I think you'd still need a hidden date time field set to the current date, but then you can use the text field with a formula similar to this, or formatted however you need, where "Current_Date" is the variable used for the hidden date time field:
=TEXT(DATEVALUE(Current_Date))