pretty much topic.
I’ve been looking into the documentation but haven’t found something which would do withTimeAtStartOfDay but for current year.
in documentation there is
withTimeAtStartOfDay()
Returns a copy of this datetime with the time set to the start of the day.
and for year there is this method
withYear(int year)
Returns a copy of this datetime with the year field updated.
which sounds like current day with custom year
Basically I want to select data from influx which are in current year maximum, and in year -1
Can i use something like withTimeAtStartOfDay() or I need to compare dates manually?
val yRclean = (Service_Clean_Count.maximumSince(now.withMonthOfYear(1).withDayOfMonth(1).withYear(2019)).state as Number).intValue
and
val yRclean = (Service_Clean_Count.maximumSince(now.withMonthOfYear(1).withDayOfMonth(1).withYear(2020)).state as Number).intValue
produces same result (which I know is wrong, as it is total number in influx to date) so does not look like right
2019 should return 8 and 2020 should return 7, but both of them returns 15
I believe that 2019 version may have return 15 as it is maximum since, but 2020 should return only 7 to this date if I’m not wrong with understanding of this feature.
The system default does not I think get set to the only/last persistence you may have installed. I think you have to take positive action to set it. It would be surprise if it didn’t fail when unset though.
It’s really easy to remove all doubt and specify
… maximumSince(time, “influxdb”) …
sometimes my brain would need to be spanked…
I know what is going on, maximumSince … damn I’m blind, maximumSince will be always the same in this case (as these are not temperatures, but counts).
I just reaplied this code for temperature on item numbers, and yes, logically 15 will be maximum since in any case.
Damn me.
hmm listing available commands there is nothing like countSince or something like that, is it?