Tuesday, April 26, 2011

QTP TIP :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

No comments:

Post a Comment