Micro Focus QTP (UFT) Forums
Invalid call argument using DateAdd - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Invalid call argument using DateAdd (/Thread-Invalid-call-argument-using-DateAdd)



Invalid call argument using DateAdd - jow - 07-16-2012

Hi,

I am a beginner in QTP and I have this error when I run my script. Please help.

Code:
departdate = DateAdd("m",1,"13-July-12")
Msgbox departdate

retdate = DateAdd("d", 5, departdate)
msgbox retdate

Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("toMonth").Select departdate 'refer to DateAdd
    Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("toDay").Select retdate

Thanks in advance.


RE: Invalid call argument using DateAdd - sshukla12 - 07-16-2012

What error u r getting.

Regards,
Sankalp


RE: Invalid call argument using DateAdd - K Gaurav Varshney - 07-16-2012

Hi Jow,
Please attach the snap shot of the screen you are working on.
According to me .....as you are using Weblist("toMonth") and as the name suggest it must take only the month value not the complete date.
Similarly, Weblist("toDay") will take only the day value and not the entire date.
For this.... store the day and month part in two different variables and then use them.

For eg
Code:
GetMonth = DatePart("m", departdate)

Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("toMonth").Select GetMonth



RE: Invalid call argument using DateAdd - jow - 07-17-2012

Hi K Gaurav Varshney,

Thank you for your help. I did the above suggestion and my script is now working Smile

Thanks againSmile
Jow


RE: Invalid call argument using DateAdd - K Gaurav Varshney - 07-18-2012

Great Smile

Regards,
K Gaurav