Date thru Date 
Author Message
 Date thru Date

Is there a simple way to take a starting date (mm/dd/yyyy or yy) and an
ending date and generate those dates in-between them and print them to a
file?  I'm building a "time-off" form and I need to enter all the dates a
person is taking off into a database to search, but I don't want that person
to type in every day he/she will be gone, that would take to long.  Are
there any built-in functions I can take advantage off or some examples
already made I could use or model after?  It starts getting complicated when
I go from month to month and start spilling over into a new year.  Thanks.

Dax



Mon, 12 Nov 2001 03:00:00 GMT  
 Date thru Date

Quote:

> Is there a simple way to take a starting date (mm/dd/yyyy or yy) and an
> ending date and generate those dates in-between them and print them to a
> file?  I'm building a "time-off" form and I need to enter all the dates a
> person is taking off into a database to search, but I don't want that person
> to type in every day he/she will be gone, that would take to long.  Are
> there any built-in functions I can take advantage off or some examples
> already made I could use or model after?  It starts getting complicated when
> I go from month to month and start spilling over into a new year.  Thanks.

I've written an object-oriented Date module, though not released, you
can take a try. Here's a code example for your problem:

use Date;
$d  = new_date Date 1999,6,15;
$to = new_date Date 1999,7,15;
while ($d < $to) {
    print $d->as_string("format" => "%Y-%m-%d"), "\n";
    $d++;

Quote:
}      

Look at
        http://user.cs.tu-berlin.de/~eserte/src/perl/Date/Date-0.11.tar.gz

Regards,
        Slaven

--
use Tk;$c=tkinit->Canvas->pack;$x=45;for(split/_/,'KPI1_+09IPK_K;-OA1_+K!;A__1;
Q!7G_1+QK_3CLPI90,_+K!;A_+1!KQ!.N_K+1Q!.F_1+KN.Q__1+KN._K+1Q!.F_1+KN.Q_+1Q__+1!
KQ!.N_1;Q!7G_K3,09Q_+1!K.Q_K+1Q!.F_1+KN.Q'){s/\n//g;for(split/!/){$c->create(
'line',map{$a=-43+ord;($x+($a>>3)*2,123+($a&7)*2)}split//)}$x+=12}MainLoop



Tue, 13 Nov 2001 03:00:00 GMT  
 Date thru Date

Quote:

>Is there a simple way to take a starting date (mm/dd/yyyy or yy) and an
>ending date and generate those dates in-between them and print them to a
>file?

Use mktime to convert noon on the first date and 3 pm on the second
date to a seconds-since-the-epoch value.  Then iterate:
  for ($t=$start; $t < $end; $t += 86_400) {

    printf "%.4d-%.2d-%.2d\n", 1900+$t[5], 1+$t[4], $t[3];
  }

(I chose noon and 3 pm to make it unlikely that a local time shift,
such as DST entry/exit, would affect the results.)

                --Ken Pizzini



Tue, 13 Nov 2001 03:00:00 GMT  
 Date thru Date

Quote:

> Is there a simple way to take a starting date (mm/dd/yyyy or yy) and an
> ending date and generate those dates in-between them and print them to a
> file?  I'm building a "time-off" form and I need to enter all the dates a
> person is taking off into a database to search, but I don't want that person
> to type in every day he/she will be gone, that would take to long.  Are
> there any built-in functions I can take advantage off or some examples
> already made I could use or model after?  It starts getting complicated when
> I go from month to month and start spilling over into a new year.  Thanks.

Perl modules are you friend.

See http://www.perl.com/modules/by-module/Date/.

With Date::Calc, you would do this as follows:

-------------------- cut here -------------------- cut here --------------------
#!/sw/bin/perl -w

use Date::Calc qw(Delta_Days Add_Delta_Days);


for ( $i = 0; $i <= $j; $i++ )
{


Quote:
}

-------------------- cut here -------------------- cut here --------------------

Hope this helps.

--

    http://www.engelschall.com/u/sb/whoami/
    http://www.engelschall.com/u/sb/download/
    http://www.perl.com/CPAN/authors/id/STBEY/
    http://www.oreilly.de/catalog/perlmodger/bnp/



Tue, 13 Nov 2001 03:00:00 GMT  
 Date thru Date
I'd like to thank everyone that responded to me.  I've seen that you can
find just about everything you ever wanted on the "WWW", but newsgroups are
really where it's at...and obviously everyone here knows that, but I'm a
beginner, I'm getting there.  Thanks again.

Dax



Tue, 13 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Need program to calculate dates between 2 dates

2. Where are the Date::Parse and Date::Format pm's located

3. How to date/time convert to numeric date format in DOS perl

4. Perl:get file date or sort files by date

5. date.pl - A date handling library

6. How compare two dates or convert date to number

7. date/time - seconds == date/time?

8. date string to date format

9. Date Conversion from seconds to MySQL Date

10. Date::Calc julain date conversion?

 

 
Powered by phpBB® Forum Software