Problem with date in perl!!

Hi All,
I am facing an issue with perl..
I have a perl script that executes the stored procedure and puts the data in a file. In stord proc we have one date column also. In table from which it is fetching the data, date is in the form "14/03/2010 00:00:00.000" (DD/MM/YYYY). But when the perl script is putting the data in the file it is writing that date column as "Mar 14 2010 00:00AM". Not sure why this conversion is happening!! Though we are not using convert functions anywhere. I want the date in the same format as it is in the table "14/03/2010 00:00:00:00".

Please assist!!
Thanks in Advance!!

Please paste the relevant code snippet. I'm guessing that you're using localtime. See localtime - perldoc.perl.org for changing the format.

If I understood correctly, you have to convert date into your format, you can try the below select statement.

SELECT TO_CHAR(date_column, 'DD/MM/YYYY HH24:MI:SS') AS New_Date from tablename

Let me clarify the issue that I am facing..

There is a table
create table MyTable
(
S_No int,
date datetime
)

The data in it is as :

select * from MyTable

1 14/03/2010 00:00:00.000
2 12/04/2010 00:00:00.000

Date is in DD/MM/YYYY format in the table.

But now when I am fetching the same data through perl and writing it in a file with pipe separated values, it is coming up as:

more file.txt:

S_No|date
1|Mar 14 2010 12:00AM
2|Apr 12 2010 12:00AM

The format of date is coming up as different in a file from what we have in table. I want it to be same as that of table.
While investigating, I also got to know that not only in perl, if we do simple isql for sybase and redirect the output to the file, date gets converted to 'Mar 14 2010 12:00AM' irespective of the format it is in the table.
What I am not getting is how unix/shell/perl script is converting the date themselves? and how do I keep it the way it is in table?

Thanks

Try this perl code,

$dt="Mar 14 2010 12:00AM";
$new_dt=`date -d "$dt" '+%d/%m/%Y %T'`;
print $new_dt;
1 Like