This topic is locked
[SOLVED]

 row color based on Date Field, Date less than Current Date

6/6/2008 9:05:49 AM
ASPRunnerPro General questions
M
mlgill author

I want any row on my list page to have a red background if the "ElasticDueDate" field has a value of less than the current date. I can't get it to work. I assume my code is wrong and/or in the wrong place. I have it in the ListOnLoad event.
if rs("EleasticDueDate")<"NOW()" then

sShadeClass = "style=""background-color:red"""

end if

N
nitescan 6/6/2008

I'm working on a similar issue but need to have the color change only after 5 days.
I can get the following to work but am having trouble pulling the current date:
This is entered in the List Page > After record processed section:
IF Row("1First_Issue_Date_value") < "6/6/2008" THEN

Row("shadeclass")="style = 'background:red'"

END IF
-Nitescan

N
nitescan 6/6/2008

To resolve my issue with comparing differences in dates I did the following:

  1. Create an extra field in my SQL server to show the difference in days using the "Computed Column Specification" section and the following code:
    datediff(day,[start date],[end date])
  2. Then in ASPRunner on the Events section, List page, After Record Processed section I entered the following:
    IF Row("1Field_Name_value") > "5" THEN

    Row("shadeclass")="style = 'background:orange'"

    END IF
    • Note: The 1 has to be in there and _value has to be there after the field name
      Hope this helps,

      Nitescan



M
mlgill author 6/6/2008

ugh - -I'm getting closer, but still no go.
This is turning ALL ROWS red, even if the date is greater than NOW()
This is driving me crazy.
List page: After record processed

Sub BeforeMoveNextList(rs,row,col)

'** Custom code ****

IF Row("1ElasticDueDate_value")<"Now()"THEN Row("shadeclass")="style = 'background:red'" END IF
End Sub ' BeforeMoveNextList

D
dlangham 6/6/2008

Try this:

IF Row("1ElasticDueDate_value")>="Now()-1"THEN Row("shadeclass")="style = 'background:red'" END IF
C
Codea 6/7/2008

Hi mlgill,

Have a "Captain Cook" (a look) at Cell Formatting - Backround Colour Topic. I entered this posting in 2006 and the responses helped me with Cell backround colour based on a value in the field. It might help point you in the right direction.
Cheers

Tony <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=30083&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' />