On Sun, 22 Jun 2003 at 16:57, Scot Robnett opined: SR:How would one go about determining if something is 3 days old, 3 months old, SR:1 year old, etc., based on the following scenario? SR: SR:The date that a user subscribes to our site is stored in a MySQL database in SR:the DATE format yyyy-mm-dd. So column 'SubscribeDate' looks like 2003-06-18, SR:for instance. SR: SR:When I pull that value out of the column, how do I do a measurement to SR:determine its age? SR: SR:<!-- snip --> SR: SR:# Get username from form selection SR:my $subscriber = $q->param('user'); SR: SR:# Connect to DB SR:my $dbh = DBI->connect("DBI:mysql:db_name:localhost","usr","pass") or die SR:"Could not connect to DB: $!"; SR: SR:# Prepare and execute statement SR:my $sth = prepare("SELECT SubscribeDate FROM UserData WHERE UserName = ?"); SR:$sth->execute($subscriber); SR:while(my($data) = $sth->fetchrow_array) { SR: my $subscription_age = # HOW WOULD I DETERMINE THIS? SR: print qq($subscriber\'s account is $subscription_age old.\n); SR:}
if you want to do the calculation in your sql, look into using the date_sub() function. if you want to do it in perl, try using date::calc http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#IDX1303 http://search.cpan.org/author/STBEY/Date-Calc-5.3/Calc.pod -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]