Date Format Comparison Issue

Posted by  marcel ethan
 1328  View(s)
Rate this:

I need to execute an condition where after starting from 150 days from today using the system date format.

String test = DateTime.Now.ToString("dd.MM.yyy");

String test2 =DateTime.Now.AddDays(150).ToString("dd.MM.yyy");

if (test == test2)//Not sure how to do it in IF condition here for date tim



Any help on this would be great.

  1. Re: Date Format Comparison Issue

    Hi Marcel,

    var dateToUse = DateTime.Now; // can be any DateTime value, if you use DateTime.Now the condition is useless

    var date1 = dateToUse.Date; // Get Date part

    var date2 = DateTime.Today.AddDays(150);

    if (date1 == date2)

        ;  // Do something if dates are equal