I’m using MySQL as persistence, and is up and running…
I log my current consumption and some other data.
I wanna make some rules that collect data and sum them up for last week/month and so on, meaning I must have a “delta” value from let’s say midnight and 1day/week/month back and then get the total consumption in that time…
I can’t get that working - anyone done the same or can get me a clue?
You can’t do this directly with Joda DataTime. You have to get the epochs (e.g. now.millis), subtract the two from each other which gives you the duration in milliseconds. Then you need to do the math to convert the milliseconds to days:hours:minutes:seconds:miliseconds.
Okay… then I easily can get the start of the day,
But how do I then let’s say get data from one week back?
When I calculate the start time of day, then I should use a command for getting 7 days return? That wouldn’t work for me?