SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Aug 2004
    Location
    Bloomington, IL
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Problem facing in comparing two dates

    Hi friends,
    I am facing a problem in comparing two dates.
    The problem is i write a program
    that will fetch the date in the cell from webtable(Not todays date, the date will be anydate)
    and store that date in a variable.
    After that comparing the date with the local datatable which will be provided by us.
    the comparison is like this
    if text = datatable("items",dtlocalsheet) then
    msgbox "Passed" & text
    else
    msgbox "Failed " & text
    end if

    For all the cases it was saying Failed even the two dates are correct.
    This simple problem giving me a lot of headache.

    Thanks&Regards,
    Ashok.

  2. #2
    Senior Member
    Join Date
    Feb 2004
    Posts
    339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    Hi, are you sure that the variable and value in the data table are of the same type? That might be the problem.

  3. #3
    Senior Member
    Join Date
    Jun 2003
    Location
    Tampa, FL
    Posts
    372
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    A few things to be careful of -- first, almost always, anything you get from the app is text. Depending on how you are setting up the datatable, you may be pulling an actual date out of that. So, 10/04/04 when pulled out of the datatable and put into a variable, and then converted to a simple numeric representation, is 38264. But what you pulled out of the app is "10/04/04" (assuming todays date just to keep it simple) Since the number 38264 is definetly not the same as the string "10/04/04", that fails. Further, if you force the number to be a string, then you will compare "38264" to "10/04/04", and that will also fail. You have to either put the data into the datatable as text, or do some date conversions in your code...how to do this can be found in the VB Script reference, available from the help menu in QuickTest.

    Good Luck
    David

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    Bloomington, IL
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    David,
    How to convert it into date format, Bcz i didnt find it.

    Thank u,
    Ashok.

  5. #5
    Member
    Join Date
    Mar 2004
    Location
    Chennai
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    Hi Ashok,
    I am not sure in which format you have stored in your datatable. If your date is having leading zeroes, then the date will get formatted by cutting the leading zeroes.

    Check whether the format is same in both the places

    I hv tried this and it works

    x="09/09/2004"
    If x=Datatable("A",dtGlobalsheet) then
    msgbox "passed"
    Else
    msgbox "Failed"
    End If

    Datatable consists of ="09/09/2004"

    Thanks
    Never Say Never

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    198
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    MyDate = "October 13, 2004" ' Define date.

    MyNewDate = CDate(MyDate)

    This will convert the string to a Date data type. use MyNewDate for comparison now.

    Hope this solves your problem.
    <font color="red">I test. Therefore I am. </font>
    http://testingthoughts.blogspot.com

  7. #7
    Junior Member
    Join Date
    Aug 2004
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    did u try
    FormatDateAndTime() function?? it worked out similar problems for me.

  8. #8
    Junior Member
    Join Date
    Aug 2004
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem facing in comparing two dates

    Sorry guys
    that was FormatDateTime(your_date_var, date_format)
    with date_format = 0,1,2,3 or 4

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 8.82%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:21 PM.

Copyright BetaSoft Inc.