I have a line chart that works fine with the following query:
SELECT peakdate, peakusage
FROM peaktable
WHERE peakDate BETWEEN '#arguments.dtBegin#' AND '#arguments.dtEnd#'
ORDER BY peakdate
The date output looks something like: 2014-01-01 00:00:00.0 and I have no trouble converting this to milliseconds for the datetime chart.I use the JavaScript getTime() function to convert the date and all is well.
Now, instead of displaying all the data points on the chart, I need to display the MAX peak for each day. Here is the query I wrote that works well in SQL Server:
SELECT convert(varchar(10), peakdate, 120) as peakdate , MAX(peakusage)
FROM peaktable
WHERE peakDate BETWEEN '#arguments.dtBegin#' AND '#arguments.dtEnd#'
GROUP BY convert(varchar(10), peakdate, 120)
ORDER BY convert(varchar(10), peakdate, 120)
The date output of this looks like 2014-01-01 with no time on the end. I kept it at varchar(10) in order to group at the date level. Unfortunately the JavaScript getTime() function throws an error because there is no time element attached to the date. So I thought I was being clever and I concatenated 00:00:00.0 to the end of the date in the SQL statement, but it still is throwing an error. I guess JavaScript did not see it as a date:
SELECT CONCAT(convert(varchar(10), peakdate, 120),' 00:00:00.0') as peak , MAX(peakusage)
FROM peaktable
WHERE peakDate BETWEEN '#arguments.dtBegin#' AND '#arguments.dtEnd#'
GROUP BY convert(varchar(10), peakdate, 120)
ORDER BY convert(varchar(10), peakdate, 120)
Does anyone have any ideas on how to use a date object with no time element in a Highcharts datetime chart? The next query I am going to have to chart is display the peak point for the month. So the date format will look like yyyy-mm.