Page 1 of 1

Month's and year's number of rainy days

Posted: Wed 10 Apr 2013 7:40 pm
by mlj1
Hi to all,
I have seen, on others websites, the month's number of rainy days and the year's number of rainy days.
Is it possible to have the same with Cumulus (with or without the possibility to set a treshold, ie >1mm for example)
I could not find a webtag to do that.
Thank you in advance for any answer.
Marcel

Re: Month's and year's number of rainy days

Posted: Wed 10 Apr 2013 7:47 pm
by steve
The number of dry and wet days for any month or year (or any other period) can be displayed on the "This month/year/period" screens in Cumulus. But there aren't currently web tags for this month's or this year's figures because the counts aren't currently stored anywhere.

Re: Month's and year's number of rainy days

Posted: Wed 10 Apr 2013 7:53 pm
by mlj1
Thank you very much Steve for your fast answer, as usual.
Best regards,
Marcel

Re: Month's and year's number of rainy days

Posted: Tue 16 Apr 2013 9:09 pm
by bigmac
Hi Marcel,

Whilst there isn't a webtag as such, I do a similar thing on my website , although in fact I ask the exact opposite, as in the UK it is nice to know how many days it didn't rain!
I use a MYSQL query to do this so you do need to be running this on your site, although there may be other ways to do it through Java scripts.

This is the query and code I use for the current year, which other members from the forum helped me create:

Code: Select all

$querytydnr='SELECT COUNT(TotRainFall) as daysnorain FROM Dayfile WHERE YEAR(LogDate)=YEAR(NOW()) AND TotRainFall=0';
$resulttydnr=mysql_query($querytydnr)or die('Error: '.mysql_error());
.
.
<?php while($row=mysql_fetch_object($resulttydnr)){?>
		<td><?php echo $row->daysnorain;?></td>
					<?php
					}
					?>
You would, I guess, change the "...AND TotRainFall=0" in the query to "...AND TotRainFall>0" to get the number of days it rained.

You can obviously change it to look at per month as well, but I found this to be more complicated for some reason (I am not a MYSQL expert, in fact I am a complete novice so my code is not what you would call "tight" and hence the reason why my month code is done in a different way to my year code), but through trial and error I got it to work:

Code: Select all

<?php $resulttysmdnr=mysql_query("SELECT COUNT(TotRainFall) as daysnorain FROM Dayfile WHERE YEAR(LogDate)=YEAR(NOW()) AND MONTH(LogDate)=$mo AND TotRainFall=0")or die('Error: '.mysql_error());?>
					<?php while($row=mysql_fetch_object($resulttysmdnr)){?>
					<td><?php echo $row->daysnorain;?></td>
					<?php
					}
					?>
For the month query, I wanted it based on a user selected month hence the $mo variable which is passed through a "select" drop down box code option.

Hope that helps you in some small way, as many others have helped me on here :D