Comparing Dates in C# , selenium RC

Example to convert string to date time variable and also compare two date time variable.
string Firstdate = selenium.GetText(FirstDate_xp);
string Nextdate = selenium.GetText(Nextdate_xp);
DateTime date1 = Convert.ToDateTime(Firstdate);
DateTime date2 = Convert.ToDateTime(Nextdate);
int result = DateTime.Compare(date1, date2);
//Compare function returns
//0 if both dates are equal
//1 if date1 is recent than date2
//-1 if date2 is recent than date1

If you found this solution helpful or have something extra to add, feel free to share it here by commenting below.


2 thoughts on “Comparing Dates in C# , selenium RC

  1. Ramesh says:

    You guys are doing an amazing work by publishing the uniqueness of Selenium Tool… I am also into Automation for the past 8 yrs but I have been automating in PERL with our own PERL framework. Now I am working for media where we use Selenium and one of my other team uses WebAii. The scripting langauge we use is also c#. So, all your posts are really helpful to know more of selenium.

    Thanks,
    Ramesh

    • Pavandeep Puddupakkam says:

      Thanks Ramesh; Most of the articles on the site are in C# and Java. We are using Selenium RC – Selenium 1.0 (coding in Java and C#) and Webdriver – Selenium 2.0 in Java. If you want to share any articles please feel free to email I can set up the account.

      Cheers
      Pavandeep Puddupakkam

Leave a Reply

Your email address will not be published. Required fields are marked *