Kalaiyarasan
Kalaiyarasan

Reputation: 297

Print complete date and time from Oracle database field

My perl script :

my $dbh = DBI->connect("DBI:Oracle:MIGSTG","AI","migrate") or die " can't connect to db";
$data = "select package_id,action,line_seq,status,entry_date from pack_pr_queue where package_id = :p1";
$sth = $dbh->prepare($data) or die " cannnot prepare the select";

$sth->bind_param( ":p1", $package );
$sth->execute() or die "cannot execute";

while (@row = $sth->fetchrow_array) {
  print "@row";

passing the value 3687898 for p1

I'm getting this output from the script

3687898 Planned Release 2 OPEN 20-MAY-13

But from Toad I get

3687898 Planned Release 2   OPEN    5/20/2013 3:40:36 AM

I want to get a output with complete date and timing ( 5/20/2013 3:40:36 AM )

Please give a suggestion to me

Upvotes: 1

Views: 1073

Answers (1)

Jakub P
Jakub P

Reputation: 542

Use to_char on entry_date:

to_char(entry_date,'DD/MM/YYYY HH:MI:SS AM')

$data = "select package_id,action,line_seq,status,to_char(entry_date,'DD/MM/YYYY HH:MI:SS AM') from pack_pr_queue where package_id = :p1";

Upvotes: 3

Related Questions