klipkop
Posts: 16
|
| Posted: 06/11/2007, 2:05 PM |
|
Hi
I am battling to compare 2 datetime fields in C#. I have tried numerous solutions on the web.
Have two dates DueDate and now. IF DueDate is before Current date then the DueDate text should be red
Tried the following and keep getting errors on the compare:
if (DateTime.Compare(DataItem.DueDate.Value,DateTime.Now) < 0)
{
DataItem.DueDate.Text = "<b><font color='red'>" +
(DataItem.DueDate.Value).ToString() + "</b></font>";
}
Tried to declare two variables
DateTime DueDate = DataItem.DueDate.Value ;
/DateTime DateSys = DateTime();
IF (DueDate < dateSys)
Then ....
Errors - cant compare the two fiels
Then I did a DateTime.ConvertTo.String which some c# samples suggested. Then getting a error can't compare two strings with < or =
I you can see I am not acoder but I can help myself 90% of the time. Not on this one
Please help
|
 |
 |
|