Page 1 of 2

This day last year page

Posted: Sat 30 Jun 2012 5:46 pm
by bigmac
I have seen on a few peoples websites, a "this day last year" page. Having looked through the forum and failed to find reference to it, I wasn't sure if this was something people have done off their own back or if it was adapted from other code. Does anyone know if this was covered in a forum topic or can give me a starting point to develop this myself?

Thanks.

Re: This day last year page

Posted: Sat 30 Jun 2012 6:28 pm
by steve
Can you give a link to an example of that? One of the things I was going to add was a set of web tags with daily stats (the sort of stuff that goes into dayfile.txt) that would be accessible via a "day=n" parameter (and "month=n" etc), so you could get a particular value for n days ago, up to a year ago (e.g. <#dailyhightemp day=365>); rather like the 'recent history' tags I introduced in build 1033. There have often been complaints that Cumulus was lacking in that sort of data compared to other software, and it took quite a bit of work to finally provide it. But it doesn't look like anyone was interested in it after all, so I put the "daily" version on hold.

Re: This day last year page

Posted: Sun 01 Jul 2012 1:22 am
by bigmac
[quote="steve"]There have often been complaints that Cumulus was lacking in that sort of data compared to other software[\quote]

Steve, one thing you can never be accused of is lacking in anything (Cumulus wise!). To paraphrase your own description of Cumulus, it is something you do in your spare time and you don't make a living from it, ergo, nothing is lacking, it simply is not a feature that has yet been implemented into an already fantastic piece of "hobby" software, and I don't mean hobby software disrespectfully!

Anyway, to answer your question, here is a typical example I like from Helens website: http://www.lalocherie.com/weather/todayprevyears.php

This isn't something I really expect you to implement Steve, I'm sure it is something the community have already resolved, I simply haven't been able to find the correct posting for it!

Thanks anyway Steve.

Re: This day last year page

Posted: Sun 01 Jul 2012 8:08 am
by steve
Yes, that type of page is exactly the sort of thing that would be made easier with the web tags I was proposing. I suspect Helen is using an SQL database made from the contents of dayfile.txt. That's a superb web site, it really makes me pleased to see things like that done with the data Cumulus supplies.

Re: This day last year page

Posted: Sun 01 Jul 2012 8:32 am
by nitrx
steve wrote:Can you give a link to an example of that? One of the things I was going to add was a set of web tags with daily stats (the sort of stuff that goes into dayfile.txt) that would be accessible via a "day=n" parameter (and "month=n" etc), so you could get a particular value for n days ago, up to a year ago (e.g. <#dailyhightemp day=365>); rather like the 'recent history' tags I introduced in build 1033. There have often been complaints that Cumulus was lacking in that sort of data compared to other software, and it took quite a bit of work to finally provide it. But it doesn't look like anyone was interested in it after all, so I put the "daily" version on hold.
I can remember I asked for something like that your anwwer was that 365 days shouldt ask a lot of memory https://cumulus.hosiene.co.uk/viewtopic.php?f=20&t=7348

Re: This day last year page

Posted: Sun 01 Jul 2012 8:53 am
by steve
nitrx wrote:I can remember I asked for something like that your anwwer was that 365 days shouldt ask a lot of memory https://cumulus.hosiene.co.uk/viewtopic.php?f=20&t=7348
That's not the same thing. I'm not talking about giving all of the 'current' values back over a 365 day period, I'm talking about the daily highs and lows etc. One set of data for each day.

Re: This day last year page

Posted: Sun 01 Jul 2012 9:01 am
by nitrx
steve wrote:That's not the same thing. I'm not talking about giving all of the 'current' values back over a 365 day period, I'm talking about the daily highs and lows etc. One set of data for each day.
Aha sorry, so we can't see a feature like you mentioned ?

Re: This day last year page

Posted: Sun 01 Jul 2012 9:07 am
by steve
nitrx wrote:Aha sorry, so we can't see a feature like you mentioned ?
It's possible, yes.

Re: This day last year page

Posted: Sun 01 Jul 2012 9:10 am
by nitrx
That should be great :!:

Re: This day last year page

Posted: Sun 01 Jul 2012 9:15 am
by duke
steve wrote:
nitrx wrote:Aha sorry, so we can't see a feature like you mentioned ?
It's possible, yes.
I don't know how Steve ever gets the time for all he does. Are the days longer up there :P .

Re: This day last year page

Posted: Sun 01 Jul 2012 9:23 am
by nitrx
Today (sunday july 1st) 1 second longer :D

Re: This day last year page

Posted: Sun 01 Jul 2012 9:34 pm
by Hillbilly
Hi
Anyway, to answer your question, here is a typical example I like from Helens website: http://www.lalocherie.com/weather/todayprevyears.php
Glad you like the page.
I suspect Helen is using an SQL database made from the contents of dayfile.txt.
- Steve is dead right that is exactly what I set up using an SQL database as set up by DAJ http://wiki.sandaysoft.com/a/ImportCumulusFile This was very clearly set out and apart from a minor headache trying to get my own brain round it I cannot fault David's clear instructions.

Following that I had to try and contrive a bit of SQL to get the data out again. But I had no idea how to do it, so after some research, have ended up with MYSQL code that works and provides the desired results for display on a PHP page. So to make this work, you need to be using/be able to use PHP on your website.

I have attached the relevant query, but have to declare up front that I make no claims about the efficiency of the code (indeed I am absolutely sure that the coding experts on the forum would shudder at the sight of it ;) ) or whether I have used the correct commands. I am happy to learn how to improve this if anyone has any better methods. All I can say is it does the job...

But of course if Steve were to develop the web tags he mentions
One of the things I was going to add was a set of web tags with daily stats (the sort of stuff that goes into dayfile.txt)
this would make life much easier for everyone. I too have no idea how Steve finds time to produce what he does already but I am sure such web tags would provide a real benefit to many people :D

To provide data for two years ago I replace INTERVAL 1 YEAR with INTERVAL 2 YEAR
I use the php variables created at the required points on the PHP page. The method for connecting to the database is taken directly from David's SQL guidance on displaying the dayfile data on a History page.

Hope this helps.

Edited to move code to text file

Re: This day last year page

Posted: Mon 02 Jul 2012 12:33 am
by tobyspond
Helen,

Thank you for sharing. I have long admired your data rich site.

Kerry

Re: This day last year page

Posted: Mon 02 Jul 2012 3:24 pm
by bigmac
This is excellent Helen, many thanks.
I had cobbled together a simple SQL query and even managed to get a number outputted that was correct, but it was based on hard coding a particular date in. The bit you've included about the day and year query helps enourmously.

Like you I have used David's excellent instructions and have now started trying to learn the SQL side of things to get the data I want, let's just say it has been a steep and frustrating learning curve, but your post has given me renewed vigour!

Coupled with what I have already learnt, your SQL query makes a lot more sense about how I achieve things.

Hopefully I can return the favour to others one day.

Cheers again.

Re: This day last year page

Posted: Mon 02 Jul 2012 6:22 pm
by Hillbilly
Kerry, thanks for the kind words.

Bigmac, pleased you have already set up your database and glad to be of assistance in helping you move to the next stage. Good luck, have fun. 8-)