Add years to date value

Hello community,

I need your help for transform data/date.
In grafana, I have a date value (DD/MM/YYYY), I would like to add 2 years to this date (18/04/2022 → 18/04/2024).
What I can do ?

Thank you for your help

Anthony

When you say “In Grafana, I have a date value”, where does this date come
from?

Is it from some query on your back-end data source (if so, what is that data
source?) or is it from your time picker in Grafana, or… what?

Antony.

1 Like

Thank you for your reply.

The value comes from zabbix which monitor a UPS (BatteryLastReplacedDate).
I just apply time unit (time:DD/MM/YYYY) by default the value is MM/DD/YYYY.

Now I would like to add 2 years to this date to display the batterie replacement date (+ 2 years or 48 months).

You can add 63072000000 (60(s)*60(m)*24(h)*365(d)21000(ms))

to your existing date, this wont be accurate on leap years…

Great, it’s perfect !
Thank you very much :+1:

1 Like