How to append zero(0) to user defined date?

Scenario:- Creating date in user defined format like MM/DD/YYYY?

Solution:- In one of our application automation, we came across a situation, where we 
wanted to validate the date displayed on the AUT, for that we created the logical date to match with Actual Result .

But our validation was failing, reason being, for the single digit dates like 2nd month it was coming as ‘2’ but in our AUT it was getting displayed as ’02’.

Logic:-To overcome this situation we created very agile and simple function.
We separated the required date into month,day and year part, concatenated ‘0’ to all the 
parts and took the right most 2 digits, to create the required date format .We created date 
in the format of ‘MM/DD/YYYY’,and the given function can be modified to return date 
in any of the required patterns.

Date Formatting in UFT or QTP

One reply on “How to append zero(0) to user defined date?”

Hi, how to call this function from the script (how to set the date) please show me an example.
Browser("title:=.*").Page("title:=.*").WebEdit("html tag:=INPUT", "name:=q", "type:=text").Set Here how can i set the date

Leave a Reply

Your email address will not be published. Required fields are marked *