Friday 2 August 2013

Explain DateAdd function in QTP with example.

Dateadd function is used to find the future date or old date in QTP.

For example -
Let say you are testing a trading application where you need to calculate the settlement date for a given trade with trade date as say today.

Now the formula for finding the settlement date is -

settlement date = trade date + 3 business days

In such scenarios you will have to add 3 business days to given trade date.

You can make use of dateadd function in QTP.

print dateadd("d",3,now) 

Above statement will add 3 days to current date and return the date.
You can also find any previous date using above syntax.

print dateadd("d",-1,now) 
This will calculate yesterday's date

print dateadd("d",1,now) 
This will calculate tomorrow's date

Syntax of DateAdd function in QTP.

Dateadd(interval_Type, Interval_Units, date)

Interval Type can be of below types.

yyyy -  Year
m  - Month
d  - Day
h  - Hour
n  - Minute
s  - Second

Please give your inputs, suggestions, feedback to Us about above QTP topic. 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.