Hi -
A silly question is one not asked...
This script:
#!/usr/bin/perl
use strict;
use warnings;
# scalar context - prints 'readable' date
my $now = localtime;
print "$now\n";
# list context - returns a list of date parts
my @parts = localtime;
print "$_\n" for (@parts);
returns this:
Fri Nov 8 11:20:44 2002
44
20
11
8
10
102
5
311
0
Now I really don't know what you want to do, but
the above is the essence of localtime.
Look in the localtime documentation for a full description
of the date parts.
Aloha => Beau.
-----Original Message-----
From: Johnson, Shaunn [mailto:SJohnson6@;bcbsm.com]
Sent: Friday, November 08, 2002 10:49 AM
To: [EMAIL PROTECTED]
Subject: set date variable and range
Howdy:
Silly perl question:
I have a script where I'd like to set three date variables and pass
them along in some sql script, but I'm having a problem trying
to define the date variables using localtime().
[snip example]
#!/usr/bin/perl
use strict;
use Date::Format;
my @lt = localtime(time);
print strftime (" %x", @lt);
[/snip example]
This almost gets me what I want, but I need all 4 digits for
the year. I can try it this way, too:
[snip example]
my $day=(localtime())[3];
my $month=(localtime())[4]+1;
my $year=(localtime())[5];
my $year=$year+1900;
print "this is the value\n";
my $value="$month/$day/$year";
print $value;
[/snip example]
The result, $value, is something that I can use.
But this seems cumbersome and I need to create
a rolling 3 month window ... so I'd have to create
an anchor date (let's say, today, which to base the rest of the dates from),
a start date (the first month of the 3 month window)
and the end date (the last month of the 3 month window).
Is there an easier way to do this? I suppose what I'm looking for is
what the example in the beginning of this email shows, but I'd like to
have all 4 digits for the year and I'd only have to define 3 variables
and not a lot more.
How can I do this?
Thanks!
-X
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]