--sorry about this:
--while, yes, i do need all 4 digits for the year, i also have to
--get the entire month ... what i have below give me up to the
--date of that month. .... SO ... what i really need is to work out
--the time so that i can get the full first month, count 3 months
--up to the full 3rd month.
--so, the example script i have is:
[snip script]
#!/usr/bin/perl -w
# this works *vewy, vewy qwost* to what i want
# created 8 nov 02 -X
use strict;
use Date::Manip;
my $date = ParseDate("today");
my $startdate = DateCalc($date, "-4 months");
my $enddate = DateCalc($startdate, "+3 months");
my $newnow = UnixDate($date, "%D");
my $newstart = UnixDate($startdate,"%D");
my $newend = UnixDate($enddate,"%D");
#print UnixDate($pastdate, " this was 3 months ago ... it looks like %D\n");
print "\n";
print "this is today $newnow\n\n";
print "freq fliers start run is $newstart\n\n";
print "freq fliers end run is $newend\n\n";
[/snip script]
[snip results]
this is today 11/08/02
freq fliers start run is 07/08/02 # --- i want this to be 07/08/2002 (or,
even 07/01/2002)
freq fliers end run is 10/08/02 # --- i want this to be 10/31/2002
[/snip results]
--sorry for not being clear.
--thanks again!
-X
-----Original Message-----
From: Johnson, Shaunn
Sent: Friday, November 08, 2002 5:55 PM
To: 'Beau E. Cox'; [EMAIL PROTECTED]
Subject: RE: set date variable and range
--thanks for the reply:
--let me rephrase my question this way. i have just installed
--the Date::Manip module. i have a test that looks like this:
[test script]
#!/usr/bin/perl -w
use strict;
use Date::Manip;
my $date = ParseDate("today");
my $pastdate = DateCalc($date, "-3 months");
print UnixDate($pastdate, " this was 3 months ago ... it looks like %D\n");
print "\n";
[/test script]
--the output looks like this:
[snip output]
this was 3 months ago ... it looks like 08/08/02
[/snip output]
--this is *almost* what I want ... BUT, i need to change the
--two digit year into a 4 digit year. is there a method
--while using, say, Date::Manip, to change the results
--from 08/08/02 to 08/08/2002?
-X
-----Original Message-----
From: Beau E. Cox [mailto:beau@;beaucox.com]
Sent: Friday, November 08, 2002 4:25 PM
To: Johnson, Shaunn; [EMAIL PROTECTED]
Subject: RE: set date variable and range
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