I am trying to flag rows in a grid in the following order based on a date column
- When 2 or more days old from today
then RED - When 1 day old then YELLOW
- When 0 days old then GREEN
- When the date is in the future then
BLUE
I have the following which is working fine except for the future dates which are GREEN instead of BLUE.
Dim myDate As DateTime = CType(grdSummaryView.GetRowCellValue(e.RowHandle, "myDate"), DateTime)
Select Case Now.Subtract(myDate).Days
'2 or more days old then RED FLAG
Case Is >= 2
e.Value = ImageCollection2.Images(3)
Case 1
'1 day old then YELLOW FLAG
e.Value = ImageCollection2.Images(1)
Case 0
'Current day then GREEN FLAG
e.Value = ImageCollection2.Images(0)
Case Else
e.Value = ImageCollection2.Images(4)
End Select
I might suggest an alternate way of writing the code:
As mentioned in my initial comments, Days will return 0 unless you are at least 24 hours in the future. So if it is 2010/08/15 12:30:00 and your future date is 2010/08/16 0:30:00 then the TimeSpan is -00:12:00:00 etc and Days will be 0.