Home > DeveloperSection > Forums > Date Format Comparison Issue
marcel ethan
marcel ethan

Total Post:105

Posted on    March-06-2014 10:56 PM

 C# C# 

 1 Reply(s)
 696  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.

Pravesh Singh

Total Post:411

Posted on    March-06-2014 11:14 PM

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

Don't want to miss updates? Please click the below button!

Follow MindStick