Problem charting fields created in the Grid Application using onRecord event

[SIZE=15px]I have a simple database which has a datetime field[/SIZE]
[SIZE=15px]I have used some php to parse the date and populate the empty field using the onRecord event. This correctly populates the parsed date components (day, month, etc) into my grid.[/SIZE]

[SIZE=15px]{month} = sc_date_conv({time}, “db_format”, “mm”);[/SIZE]
[SIZE=15px]{day_of_month} = sc_date_conv({time}, “db_format”, “dd”);[/SIZE]
[SIZE=15px]$temp = sc_date_diff({time}, “yyyy-mm-dd hh:ii:ss”,“2016-01-03 00:00:00”,“yyyy-mm-dd hh:ii:ss”);[/SIZE]
[SIZE=15px]{day_of_week} = $temp - round($temp/7-.5)*7;[/SIZE]
[SIZE=15px]$timearray = sc_time_diff({time}, “yyyy-mm-dd hh:ii:ss”,“2016-01-01 00:00:00”,“yyyy-mm-dd hh:ii:ss”);[/SIZE]
[SIZE=15px]$temp = $timearray[0];[/SIZE]
[SIZE=15px]{hour} = $temp - round(($temp-12)/24,0)*24;[/SIZE]

[SIZE=15px]My problem is that these fields (month, day_of_month, day_of_week, hour) are not available in the GroupBy section so they are not available to chart. [/SIZE] I would appreciate any advice. Thanks