unable to highlight a cell [message #730979] |
Thu, 29 September 2011 16:17 |
kayanserdar Messages: 20 Registered: April 2011 |
Junior Member |
|
|
hello all,
I have been trying to highlight a cell with some time condition.
There is a time info is populated via script in a cell with following format:YY-MM-DD hh:mm:ss a
This info is refreshed daily and cell is formatted as "h:mm:ss a"
I have created 3 conditions below to highlight this cell in Yellow, Red, or Green however i always see this cell highlighted in red.
Green:if time in cell is less than or equal to 7:00:00 AM
row[X] less than or equal to
var d = new Date();
d.setHours(07,0,0);
Yellow: If time is between 07:00:01 AM and 08:00:00 AM
row[X] between
var date = new Date
date.setTime(7,0,1)
and
var date = new Date
date.setTime(8,0,0)
Red: if time is greater thanor equal to 08:01:00 AM
row[X] greater than or equal
var d = new Date();
d.setHours(08,0,1);
Not sure if there is any logic missing there but i am always getting red highlighted cell, any help is much appreciated.
Cheers,
Serdar
|
|
|
|
Re: unable to highlight a cell [message #731014 is a reply to message #730979] |
Thu, 29 September 2011 17:15 |
|
What does your expression look like for the var d = new Date();
Is the last line d.setHours... If so that is the value that will be
returned by the expression. Use something like:
var myDate = new Date();
myDate.setHours(12);
myDate.setMinutes(59);
myDate.setSeconds(59);
myDate;
Notice the last line is myDate which is what will get returned by the
expression.
Jason
On 9/29/2011 12:17 PM, kayanserdar wrote:
> hello all,
>
> I have been trying to highlight a cell with some time condition.
> There is a time info is populated via script in a cell with following
> format:YY-MM-DD hh:mm:ss a
> This info is refreshed daily and cell is formatted as "h:mm:ss a"
>
> I have created 3 conditions below to highlight this cell in Yellow, Red,
> or Green however i always see this cell highlighted in red.
>
> Green:if time in cell is less than or equal to 7:00:00 AM
> row[X] less than or equal to var d = new Date();
> d.setHours(07,0,0);
>
> Yellow: If time is between 07:00:01 AM and 08:00:00 AM
> row[X] between var date = new Date
> date.setTime(7,0,1)
> and var date = new Date
> date.setTime(8,0,0)
>
> Red: if time is greater thanor equal to 08:01:00 AM
> row[X] greater than or equal var d = new Date();
> d.setHours(08,0,1);
>
> Not sure if there is any logic missing there but i am always getting red
> highlighted cell, any help is much appreciated.
>
> Cheers,
> Serdar
|
|
|
|
Re: unable to highlight a cell [message #731294 is a reply to message #731071] |
Fri, 30 September 2011 14:22 |
|
I understand, but the last line has to by d in your case not d.setHours.
Take a look at the attached example.
Jason
On 9/29/2011 4:46 PM, kayanserdar wrote:
> I have tried below so i can compare hours to hours and minutes to
> minutes, still same.
> row["X"].getHours() ,row["X"] .getMinutes()
>
> today's info is retrieved on that cell is 2011-09-29 03:54:27 and i
> would like to compare this info with 2011-09-29 07:00:00. and when data
> in that cell is less than or equal to 2011-09-29 07:00:00 it should be
> highlighted as Red.
>
> Data on hat cell will be refreshed every day so tomorrow i will have
> 2011-09-30 HH:mm:ss and i still want to compare with 2011-09-30 07:00:00
> that is why i have used below expression:
> var d = new Date();
> d.setHours(07,0,0);
>
> I hope this make more clear.
>
> Cheers,
> Serdar
|
|
|
|
Powered by
FUDForum. Page generated in 0.03089 seconds