【问题标题】:Print complete date and time from Oracle database field从 Oracle 数据库字段打印完整的日期和时间
【发布时间】:2014-03-16 04:59:43
【问题描述】:

我的 perl 脚本:

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";

将值 3687898 传递给 p1

我从脚本中得到这个输出

3687898 Planned Release 2 OPEN 20-MAY-13

但我从蟾蜍那里得到

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

我想得到一个完整的日期和时间的输出(5/20/2013 3:40:36 AM)

请给我一个建议

【问题讨论】:

标签: oracle perl datetime dbi


【解决方案1】:

在 entry_date 上使用 to_char:

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";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-27
    • 1970-01-01
    • 1970-01-01
    • 2015-05-14
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    相关资源
    最近更新 更多