Win 2003, TS 6.5 sp1,Oracle 10gSelect DATE_FLD from anytable;The output is 2003-07-01 00:00:00(for ex)Here $stdt = the output of database date.my $tmstdt = str2time($stdt);my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($tmstdt ); $year = $year + 1900 if ( $year > 100 );$year = $year + 2030 if ( $year < 100 );$mon=$mon+1;my $s1 = sprintf("%02d/%02d/%4d",$mon,$mday,$year);I guess, in this code, no need to use two statements for year .Is there any simple way to convert database date in Perl?ThanksSri
use POSIX;...my $s1 = strftime('%m/%d/%Y %H:%M:%S', localtime($tmstdt));
Thanks for your reply. Something may be wrong...The original value is 01-Jul-2003($stdt from DB). I am using the statement likemy $s1 = strftime('%m/%d/%Y %H:%M:%S', localtime(time2str($stdt)));The output I am getting is12/31/1969 19:00:00
Sorry 'str2time' is correct.But it is working as follows:2003-07-01 00:00:00 converts as 07/01/2003 00:00:002099-12-31 00:00:00 converts as 12/31/1969 19:00:00Any advice? Thanks