royd
8 years agoRegular Contributor
aqDateTime.Today() - date format problem.
I am getting an error while creating a new patient. The patient admission date is a month/two into the future. The admission date format calls for mm/dd/yyyy. aqDateTime.Today() produces mm/dd/yy + time.
How can I produce four digit year without the time? I need just 06/24/2017 (without the time).
Here is my code (JScript):
var currentDate = aqDateTime.Today(); var dOAdmission = aqDateTime.AddMonths(currentDate, 2); Log.Message("Today is" + aqConvert.DateTimeToFormatStr(dOAdmission, " %m/%d/%y"));
Output is logged as: "Admission date is 06/24/17 6:57:23 Normal".
Thanks.
If you want 4 digit year then you have to provide %Y instead of %y.
var currentDate = aqDateTime.Today(); var dOAdmission = aqDateTime.AddMonths(currentDate, 2); Log.Message("Today is" + aqConvert.DateTimeToFormatStr(dOAdmission, " %m/%d/%Y"));
Output[highlighted in Green] is Today is 06/24/2017 17:24:39 Normal
And for more specifiers. https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/date-and-time-format-specifiers.html
See my commentary in the screenshot