Tuesday 30 July 2013

How to find the name of the week day for given date in QTP?

You can find the name of the weekday like sunday, monday etc from a given date using below code.

There are 2 functions which help you find the name of week day or weekday name.

1. Weekday(anyvalid_date)  -  returns the numeric representation of weekday.
2. Weekdayname(intX)         - returns human readable weekday name like monday, sunday etc

print weekdayname(weekday(now))

Above statement will print the today's day name.

print weekdayname(weekday("09-jan-1986"))
'Will print thursday

To get the day name in abbreviated form use below statement
print weekdayname(weekday("09-jan-1986"), true)
'Will print thu.
Thus when you pass the second parameter as true, you will get the name in 3 letter format like sun, mon etc.

Above statement will print the name of day on 09-jan-1986.

Numeric representation of weekday is given below


1 - Sunday (default)
2  - Monday
3  - Tuesday
4  - Wednesday
5  - Thursday
6  - Friday
7  - Saturday





You can also use above statement to find out the day on which you were born.

Example to find the date of birth weekday -

Assume that your birthday is 24-oct-1985

dob = #24-oct-1985#
print weekdayname(weekday(dob))

This is how you can find the name of the weekday in QTP and vbscript.


Please find below more questions and answers on date and time in QTP.

  1. How to extract date part from timestamp in QTP?
  2. How to find the name of month of given date in QTP?
  3. How to extract time part from given date in QTP?
  4. How to extract the second part from given time stamp in QTP?
  5. Explain dateadd function in qtp with Example.
  6. How to find future date in qtp?
  7. How to get the system date in qtp?
  8. How to verify the date format in qtp?
  9. How to find the yesterday's date in qtp
  10. How to find the date difference in qtp
  11. How to get the current system date in qtp?
  12. How to get the current year in qtp?
  13. How to find the name of week day for given date in QTP?
  14. Explain now function in qtp.
  15. Explain the datediff function in qtp.



Please give your inputs, suggestions, feedback to Us. We value your thoughts.

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.