Graph bars time start

Hello to all,

I am trying to make a weekly graph which will start from Monday but Grafana starts by default from thursday. I don’t want to make changes in the server. Is there another way to fix it .

I use only Grafana connected with a database

Example (sample code query)
SELECT
UNIX_TIMESTAMP(StartTime) DIV 604800 * 604800 AS “time”,
count(idAllFaults) AS “No sync- Retail”
FROM AllFaults
WHERE
StartTime BETWEEN FROM_UNIXTIME(1621851996) AND FROM_UNIXTIME(1622456796) AND
( TTSymptom = ‘Δε συγχρονίζει’ AND FLAG=‘False’)
GROUP BY 1
ORDER BY UNIX_TIMESTAMP(StartTime) DIV 604800 * 604800

Not entirely surprising when you have used:

SELECT
UNIX_TIMESTAMP(StartTime) DIV 604800 * 604800 AS “time”

Epoch time started at 0 on Thursday January 1st 1970.

Regards,

Antony.

I send and the promql query if it helps

SELECT
$__timeGroupAlias(StartTime,7d),
count(idAllFaults) AS “No sync- Retail”
FROM AllFaults
WHERE
$__timeFilter(StartTime) AND
( TTSymptom = ‘Δε συγχρονίζει’ AND FLAG=‘False’)
GROUP BY 1
ORDER BY $__timeGroup(StartTime,7d)

I’m sorry, but I do not understand your answer.

You are taking Unix Time and finding the remainder after dividing by the number
of seconds in one week.

That means your starting point is going to be 00:00:00 Thursday because that
is when Unix Time started on 1st January 1970.

If you really want to do that calculation (time DIV 604800 * 604800) and get
results starting on a Monday, try subtracting 259200 from the timestamp first,
before the DIV.

Antony.

The first is the query from the inspect option the second is from the promql query in the panel.

Sorry if it is not so clear

Is my explanation as to why your calculation results in “zero equals the start
of Thursday” clear?

Try the command “date -d @0” on your own computer if not.

Antony.