QTP:How to convert system date to other date format?

We can use the following code to convert system date to other formats:-

   1: MyDate = Date

   2: msgbox MyDate

   3: MyDay = day(MyDate)

   4: MyMonth = Month(MyDate)

   5: MyYear = Year(MyDate)

   6: msgbox "Date in DD/MM/YYY format is - " & MyDay & "/" & MyMonth & "/" & MyYear

   7: msgbox "Date in MM/DD/YYYY format is - " & MyMonth & "/" & MyDay & "/" & MyYear

Explanation:-
1. System date in extracted into variable MyDate
3. day function extracts the day from given date.
4. month function extracts the month from given date.
5. year function extracts the year from given date

1 thought on “QTP:How to convert system date to other date format?”

  1. I want the system date as DDMMYY…how to do it? I tried the above with this it doesnt work:msgbox "Date format is – " & MyDay & MyMonth & MyYear

Comments are closed.