18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Compare two dates in sahi

yeturumuraliyeturumurali Members
edited November -1 in Sahi - Open Source
Hi,

for example , i need to validate the dates greater than this date(03/18/2011). i need to validate the dates less than this date(03/18/2011).
Is there any pre defined functions in Sahi to work with or can anyone suggest me how to validate this?

Comments

  • globalwormingglobalworming Moderators
    edited January 2012
    Hi

    you have to change to format of your date... either manually or automatic (maybe there's a javascript snipptet on the web), then u can use Date.parse() http://www.w3schools.com/jsref/jsref_parse.asp
    Then you can compare the milliseconds returned by parse() to see if a date is above or below some other

    Regards
    Wormi
  • Thanks for sparing time to me.

    But i tried this.It wil work for JS, but not sahi. Is there any predefined function in sahi.
    How to check whether the date (10/15/2011) is between the dates (7/15/2011) and (12/15/2011).

    Please help me....
  • MURAlI,

    lOGIC is
    your date:10/15/2011
    Start date:7/15/2011
    Enddate:12/15/2011
    if yourdate> startdate and yourdate<Enddate // here and is logical and

    Please try with above logic, it will works
  • The parsing is working well

    alert("Date: "+Date.parse("01/01/2000")) works with sahi
    so use ( Date.parse($yourdate) > Date.parse($startdate) ) && (Date.parse($youurdate) < Date.parse($enddate)) as mentioned by rajathummala
Sign In or Register to comment.