Link to home
Start Free TrialLog in
Avatar of lobos
lobos

asked on

compare date, if less than today

I want to turn on an indicator if this value is less than today's date.

DateTime.Parse(dr["birthday"].ToString())).ToString("MMM-dd-yyyy")

I want to turn on an indicator if this is less than today's day.
How can I do an if statement against the current date?
ASKER CERTIFIED SOLUTION
Avatar of Timbo87
Timbo87

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eternal_21
eternal_21

I think,

  if(DateTime.Parse(dr["birthday"].ToString()) < DateTime.Today)
    // birthday is less than today's date
  else
    // birthday is greater than today's date

Might be a little closer...
Avatar of lobos

ASKER

Ok can this be update the if statement a bit more I need to know if the date entered is equal to Nov.16,2004 then flag it.
I am really bad with the syntact stuff.
Thanks.
DateTime birthday = DateTime.Parse(dr["birthday"].ToString())).ToString("MMM-dd-yyyy");
DateTime today = DateTime.Parse(DateTime.Now.ToShortDateString());

if (birthday.CompareTo(today)<0)
     // birthday is less than today's date

if (birthday.CompareTo(new DateTime(2004, 11, 16)) == 0)
    // birthday is equal to Nov.16th
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial