Hi Don,

The itemRenderer's "data" Object contains BOTH fields for that row in
the dataProvider.  You can start by trying to pass the date strings into
a DataFormatter and cast as Date, or try DateField.stringToDate().  If
the format of the date string isn't compatible, and you can't change
what the server sends, you might have to parse the string manually and
create a Date object from scratch.  Once you have the two date strings
converted to Dates, you're ready to compare them.  There are a few
utilities that you'll be able to find through a search, that work with
comparing dates.  I found this very quickly (looks like it rounds to
full days though):

private function calcuateDays( start:Date, end:Date ) :int
{
       var daysInMilliseconds:int = 1000*60*60*24;
       return (  (end.time - start.time)  / daysInMilliseconds );
}
You'd probably want to use a Number instead of int, and round the number
as desired.  And, probably search anyway.

-TH

--- In flexcoders@yahoogroups.com, "Don Kerr" <fusionp...@...> wrote:
>
> I have two columns in a datadrid, startTime (e.g. 04:30 PM) and
endTime (e.g. 06:00 PM). Both are strings and varchar in the database.
>
> I want to add a column to the datagrid that displays the difference
between these two times expressed in hours (e.g. 1.5 Hours).
>
> I'm trying to use an itemrenderer to do this calculation, but I've yet
to be successful. Having trouble converting the strings to date, then
calculate the hours. Can anyone help?
>
> Thanks,
> Don
>



Reply via email to