RE: Query in Perl Programming
[email protected] ("S, Rajini (STSD)") Wed, 28 Jan 2009 11:11:13 +0000
| Newsgroups | perl.trainers |
|---|---|
| Message-ID | <96AEBFA15D710543A6A0F226BDC8AEE225FED41C72@GVW1125EXB.americas.hpqcorp.net> |
Thanks Jacinta.=20 I could find date formatter that represents date in various=20 Fomarts.=20 Is there a date Converter which converts the date,=20 Eg : given date 27-Jan-09, to be converted to 27.01.2009. -Rajini=20 =20 >-----Original Message----- >From: Jacinta Richardson [mailto:[email protected]]=20 >Sent: Wednesday, January 28, 2009 7:14 AM >To: S, Rajini (STSD) >Cc: [email protected] >Subject: Re: Query in Perl Programming > >G'day Rajini, > >S, Rajini (STSD) wrote: > >> I am new to Perl Programming and have a query in perl.=20 >>=20 >> In perl is there any system defined functions to find out=20 >the Differences in dates.=20 >>=20 >> Eg :=20 >>=20 >> Date 1 -> 26-Jan-2009 >> Date 2 -> 14-Jan-2009 >>=20 >> So the difference between two dates is 12 days.=20 > >There aren't any Perl built-in functions to do this. =20 >Fortunately there are a whole range of Date modules on CPAN=20 >that might be suitable for your needs. You will need to=20 >install whichever one(s) you choose on your system if they are=20 >not already there. There is an answer to how to find out what=20 >is installed on your system if you do: > > perldoc -q installed > >So, to find out what Date modules exist you'd search CPAN: > > http://search.cpan.org/search?query=3Ddate&mode=3Dall > >In particular I'd suggest looking at Date::Simple > > > #!/usr/bin/perl -w > use strict; > use Date::Simple qw(date); > > # Difference in days between two dates: > my $diff =3D date('2001-08-27') - date('1977-10-05'); > >If you need to convert from your date format '26-Jan-2009' to=20 >the format that Date::Simple will accept then you might want=20 >to look at the Date::Parse module as well. > >There are other Date modules that might be better suited, and=20 >I encourage you to look at them too. > >All the best, > > Jacinta > >--=20 > ("`-''-/").___..--''"`-._ | Jacinta Richardson | > `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | > (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | > _..`--'_..-_/ /--'_.' ,' | [email protected] | > (il),-'' (li),' ((!.-' | www.perltraining.com.au | >=