Thread Postgres - timestamp - date (5 answers)
Opened by Kuerbis at 2014-03-28 11:02

Kuerbis
 2014-03-28 11:02
#174459 #174459
User since
2011-03-20
955 Artikel
BenutzerIn
[default_avatar]
Hallo!

Ich wollte das letzte "SELECT" Beispiel von diesem Beitrag ausprobieren, aber es funktioniert nicht:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
my $table = 'timestampt';
$dbh->do( "CREATE TABLE IF NOT EXISTS $table ( Id INT, epoch_micro BIGINT, epoch_milli BIGINT, epoch_s BIGINT )" );
my $sth = $dbh->prepare( "INSERT INTO $table ( Id, epoch_micro, epoch_milli, epoch_s ) VALUES ( ?, ?, ?, ? )" );
my $values = [
    [ 1, 1387528449510009, 1387528449510, 1387528449 ],
    [ 2, 1387528449518239, 1387528449518, 1387528449 ],
    [ 3, 1387529362307977, 1387529362307, 1387529362 ],
];
for my $row ( @$values ) {
    $sth->execute( @$row );
}

$sth = $dbh->prepare( "SELECT TO_TIMESTAMP( extract( epoch epoch_milli ))::date FROM $table" );
$sth->execute();
$sth->dump_results;


Code: (dl )
1
2
DBD::Pg::st execute failed: FEHLER:  Syntaxfehler bei "epoch_milli"
ZEILE 1: SELECT TO_TIMESTAMP( extract( epoch epoch_milli ))::date FRO...


Kann mir jemand sagen, was hier nicht stimmt?

View full thread Postgres - timestamp - date