Calculate yesterday's date **solved**

This section covers the Meteobridge PRO, PRO2, NANO SD, Raspberry Pi and VM platforms exclusively

Moderator: Mattk

Post Reply
ValterVB
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: Sun Dec 22, 2019 8:31 pm

Calculate yesterday's date **solved**

Post by ValterVB »

With this:

Code: Select all

[th0temp-avg@[YYYY][MM][DD]13.1:--]
I have the average temperature of today at 13:00, but if I want the same thing for yesterday, how I can do it?
I have tried with:

Code: Select all

[th0temp-avg@[YYYY][MM]{* [DD]-1 *0}13.1:--]
but don't work

Thanks for an answer

Valter
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Calculate yesterday's date

Post by admin »

Please read the wiki: https://www.meteobridge.com/wiki/index. ... _Additions

[th0temp-avg@D1]

-----------

Selectors val, min, max, avg, sum, mintime, maxtime can be combined with a "@YYYYMMDDhh" specifier, which determines the point in time where the data should be taken from. This specifier also defines if data should be used on a per hour, per day, per month or per year resolution. To get data in a per hour resolution the specifier needs to define the point in time down to the hour. Example: "min@2015121909" selects minimum data from December 19, 2015 09:00 until 9:59 (on a per hour base). This is how the specifier works:

@YYYY selects data for the specified year. Example: Using "[th0temp-min@2015]" in a template will report minimum outdoor temperature of 2015. When "YYYY" is not defining a valid year but is in the range of "0000" to "0010" then "0000" is interpreted as the current year, "0001" as the previous year and so on. In that situation the 4 digit number expresses how many years to skip into the past. These skips need to be in 4-digit style, leading zeros are not allowed to be omitted.
@YYYYMM selects data for the specified month. Example: Using "[wind0wind-max@201509]" in a template will report maximum wind speed (gust) of September 2015.
@YYYYMMDD selects data for the specified day. Example: Using "[rain0total-sum@20151031]" in a template will report total rainfall on October 31, 2015.
@YYYYMMDDhh selects data for the specified hour. Example: Using "[uv0index-avg@2015110316]" in a template will report average UV index on November 3, 2015 between 16:00 and 16:59.

In addition to specify an absolute point in time (as explained above) you can also use points in time relative to now. Relative points in time can be specified in terms of years, months, days, hours and minutes as follows:

@Yn addresses yearly data n years in the past. Example: When you are in 2016 and specify "[th0temp-max@Y1]" it will return the maximum outdoor temperature of last year (2015), while "@Y3" will address data from 2013.
@Mn addresses monthly data n months in the past. Example: "[wind0wind-max@M0] will return max wind speed of current month, while "[wind0wind-max@M1]" will return max wind speed of previous month.
@Dn addresses daily data n days in the past. Example: "[th0temp-min@D7]" will return minimum outdoor temperature of the current day, one week in the past.
@hn addresses hourly data n hours in the past.
ValterVB
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: Sun Dec 22, 2019 8:31 pm

Re: Calculate yesterday's date

Post by ValterVB »

Maybe I wasn't so clear, sorry.
In this page there are 3 chart:
The first is the average temperature by each hour of today
The second is the average temperature by each hour of yesterday
The third is the average temperature by each day of the current month

For the first chart I use a template like this

Code: Select all

[DD]/[MM]/[YYYY]
[th0temp-avg@[YYYY][MM][DD]00.1:--]
[th0temp-avg@[YYYY][MM][DD]01.1:--]
[th0temp-avg@[YYYY][MM][DD]02.1:--]
[th0temp-avg@[YYYY][MM][DD]03.1:--]
[th0temp-avg@[YYYY][MM][DD]04.1:--]
[th0temp-avg@[YYYY][MM][DD]05.1:--]...
It is updated every hour

For the second I use the same template, I run it with "Event Types" = "Before each new day", but if somthing go wrong I miss the update and I must update the data in manual manner.

So if is possible to ask the average value for the previous day at specific hour I can avoid this problem, because I can run the the request for yesterday in any time I want.

PS. If I use this:

Code: Select all

[YYYY][MM]{* [DD]-1 *0}13.1:--]
it show correctly the date of yesterday, but if I use it with @ like this:

Code: Select all

[th0temp-avg@[YYYY][MM]{* [DD]-1 *0}13.1:--]
it show the average of the month not the average of yesterday at 13:00
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Calculate yesterday's date

Post by admin »

If you are looking for data of all days of the current month, you should use the export functions, which are more suited to mass export data. You are looking into the wrong direction with endless lists of template variables... this is inefficient and will not work for large volumes of data.

You can take the NOAA export templates in template folder as an example how to do exports. Please also read here:
https://www.meteobridge.com/wiki/index. ... CSV_Schema
ValterVB
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: Sun Dec 22, 2019 8:31 pm

Re: Calculate yesterday's date

Post by ValterVB »

Yes this is the perfect solution. I had not seen that it was possible to use exports with FTP.
Thank a lot.
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Calculate yesterday's date

Post by admin »

Please make sure they are delete after FTP upload (set corresponding mark in upload service definition), otherwise data will stack up and fill your storage.
Post Reply