Why don't you use mysql's Date-functions to compute the last ten days,
something along the lines of:
select * from yourtable where dateColumn >= DATE_SUB(CURDATE(),
INTERVAL 10 DAY);
Hope this helps
Tobias
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Ewen Marshall
> Sent: Thursday, September 07, 2006 12:18 PM
> To: [email protected]
> Cc: [email protected]
> Subject: Working Out Dates
>
> Hi guys,
>
> I looking for some help with dates. On a Win2k server I've
> got a MySQL database (4.1) that stores results from backup's
> on 80 servers and I want to show a webpage (using Perl 5.8)
> that shows the last 10 working days (Fri -
> Mon) results for all 80 servers. The way I'm thinking is to
> get today's date/time and subtract 1 day backwards, and work
> out the weekends and miss them out. Here's the sort of jazz
> I'm thinking about:
>
> use strict;
> my @date_time = localtime();
> my $year = $date_time[5] += 1900;
> my $monthday=sprintf("%02d", $date_time[3]); my
> $month=sprintf("%02d", $date_time[4] + 1);
>
> my $mysql_today = "$year-$month-$monthday"; # Todays date in
> mysql format my $mysql_minus1 = "$year-$month-" .
> (sprintf("%02d", $monthday - 1)); # yesterdays date in mysql
> format my $mysql_minus2 = "$year-$month-" . (sprintf("%02d",
> $monthday - 2)); # 2 days ago in mysql format print
> "$mysql_today\n$mysql_minus1\n$mysql_minus2\n";
>
> This works fine until I go back through September to August:
>
> my $mysql_minus7 = "$year-$month-" . (sprintf("%02d", $monthday - 7));
>
> This prints the day as 00 (when running on 7th Sept 2006).
> Obviously this could be coded to check for a 00 and subtract
> 1 from $month and work out how many days are now in the month
> and set $monthday to (for example running
> today) to 2006-08-31. I know there must be an easier way to
> do this but my brain has decided to stop working and would
> appreciate any of your thoughts on the easiest way to go about this.
>
> Thanks in advance for any help,
>
> Ewen
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs