Results 1 to 4 of 4
  1. #1

    Compare the Date

    Hi All,

    Dim a
    a = split(date,"/")
    'a(0) will contain montht i.e 5
    'a(1) will contain Date i.e 20
    MsgBox defaulttoDay 'the value is populated as 21

    If defaulttoDay = a(1) Then
    reporter.ReportEvent micPass,"pass","pass"
    reporter.ReportEvent micFail,"Fail","Fail"

    In this case though the defaulttoDay and the a(1) value are both same but also i am getting the fail as the result in the Result sheet . What may be the problem ?


  2. #2

  3. #3
    Advanced Member
    Join Date
    Mar 2007
    Salt Lake City, UT, USA

    Re: Compare the Date

    When you split a string (or a date) you end up with a variable type of "string", so initially a(1) is a "string" variant.

    Then when you use the line "a(1)=a(1)+1" QTP recognizes that now a(1) is a "double" variant (a number, not a string), regardless of the fact that it used to be a string.

    Then in your "If defaulttoDay = a(1) Then" line, a(1) is a "double", so as long as defaulttoDay is numeric, the line should evaluate to true. If defaulttoDay is something else, like a string, then the line will evaluate to false.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  4. #4

    Re: Compare the Date

    use the vbs-internal function CDate(expression)

    if your expression is a valid date the expression will be converted to a valid date correspondending to your local system settings.


    CDate(Date) - CDate(expression) will let you know the difference between the 2 dates

    de omnibus dubitandum

    For all Questions: Please be sure to take a look at the QTP Manual before posting any Questions, thanks for doing this



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 04:07 PM.

Copyright BetaSoft Inc.