4 messages in com.mysql.lists.perlRe: variables
FromSent OnAttachments
amy parness10 Apr 2004 11:15 
Randall D. Hobbs10 Apr 2004 20:26 
Jamie McCarthy11 Apr 2004 05:06 
Randall D. Hobbs11 Apr 2004 07:20 
Subject:Re: variables
From:Randall D. Hobbs (Mand@cox.net)
Date:04/10/2004 08:26:19 PM
List:com.mysql.lists.perl

Hi Amy... It would be much easier and more precise with the sprintf statement:

$datestart = $fromyearValue . "-" . sprintf("%02d",$frommonthWidgetValue) . "-" . sprintf("%02d",$fromdateWidgetValue + 1);

$dateend = $toyearValue . "-" . sprintf("%02d",$tomonthWidgetValue) . "-" . sprintf("%02d",$todateWidgetValue + 1);

print "$datestart\t$dateend\n";

If you have any questions, feel free to give me a shout off list...

-- Take care, Randall Hobbs Programmer - System Administrator - Chip Castle Dot Com, Inc. Web Hosting * Programming * Software http://www.chipcastle.com

On Saturday 10 April 2004 01:16 pm, amy parness wrote:

My first if statements are working and adding a 0 before numbers less than or = to 9 but the second ones (fromdate and todate) are not working. They are adding the +1 but not the 0 before numbers <=9. Does it have something to do with it being in () in the main statement?

$x=0

if ($frommonthWidgetValue <= 9) { $frommonthWidgetValue = $x.$frommonthWidgetValue; } if ($fromdateWidgetValue <= 9) { $fromdateWidgetValue = $x.$fromdateWidgetValue; }

if ($tomonthWidgetValue <= 9) { $tomonthWidgetValue = $x.$tomonthWidgetValue; } if ($todateWidgetValue <= 9) { $todateWidgetValue = $x.$todateWidgetValue; }

$datestart= $x.$fromyearValue. "-".$frommonthWidgetValue."-".($fromdateWidgetValue+1); $dateend= $x.$toyearValue. "-" .$tomonthWidgetValue. "-".($todateWidgetValue+1);

print $datestart