On Mon, 25 Oct 2004, M. Ilyas Hassan wrote: > #1 - Is there a way to add "days" to a date?
The modules that the other two respondants pointed you to are the right way to do this, but it's good to know that the way to do this by hand -- which you won't want to do, but it's good to see why not -- is to only deal with times represented as seconds. So, for example, 90 days works out to 7776000 seconds (60 secs/min * 60 mins/hour * 24 hours/day * 90 days). So you look up the Unix timestamp for the starting date. For this, let's use the time as I type this, 1098746228: $ perl -le 'print scalar localtime 1098746228' Mon Oct 25 19:17:08 2004 $ You add 90 days worth of seconds to that to get the future date: $ perl -le 'print 1098746228 + 7776000' 1106522228 $ And then you convert that back to a more conventional format: $ perl -le 'print scalar localtime( 1098746228 + 7776000 )' Sun Jan 23 18:17:08 2005 $ Or, putting it all together: $ perl -le '$now = 1098746228; $ninety_days = 7776000; $then = $now + $ninety_days; print scalar localtime $then' Sun Jan 23 18:17:08 2005 $ This isn't *that* bad, but the math gets annoying to manage manually. Using a module like Date::Calc saves a lot of effort & reduces errors. Look up the documentation for Date::Calc for usage detals. > #2 - How could I find the minimum value from table with say 80columns. How is this table represented? Is it in a database? Is it in a flat file of some kind? Do you already have it in memory in some kind of data structure? The approach to this problem depends a lot on what tools you have to work with. For this, you need to describe where this data is coming from, how you are thinking of representing it in variables, and (most important) you need to show us what code you've written to solve the problem. The date problem was a gimme, but this is a larger task with many ways it could be solved. You have to show us where you're starting from before you can expect people to fill in the blanks for you. > Please email your feedback to [EMAIL PROTECTED] I will truly > appreciate any help that you could offer. This seems to be a typo -- all discussion should stay on the list where it can be of use to everyone that is trying to learn this stuff. If you have not already done so, please subscribe to the list so that we can have the conversation on the list. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>