Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Problem with the to_timestamp function






So the start_time is a varchar column, which contains a date.


opal_app=# select job_id,start_time from job_status where job_id='app1201551799779' ;
job_id | start_time ------------------+--------------------------
app1201551799779 | 1 28, 2008 12:23:19 午後
(1 row)

opal_app=# select job_id,to_timestamp(start_time, 'M DD, YYYY  HH12:MI:SS 午後') from job_status where job_id='app1201551799779';
job_id | to_timestamp ------------------+------------------------
app1201551799779 | 2008-01-28 02:23:19-08
(1 row)

opal_app=# select job_id,to_timestamp(start_time, 'M DD, YYYY  HH12:MI:SS') from job_status where job_id='app1201551799779';
job_id | to_timestamp ------------------+------------------------
app1201551799779 | 2008-01-28 02:23:19-08
(1 row)

opal_app=# select job_id,to_timestamp(start_time, 'M DD, YYYY  HH:MI:SS') from job_status where job_id='app1201551799779';
job_id | to_timestamp ------------------+------------------------
app1201551799779 | 2008-01-28 02:23:19-08
(1 row)


It seems that the to_timestamp does not work properly in this case, when it comes to parsing the hours. I verified that this problem happen no matter what the input hours is and the result is always 00:min:sec or 02:min:sec.

opal_app=# select job_id,start_time from job_status where job_id='app1201563668439';
job_id | start_time ------------------+-------------------------
app1201563668439 | 1 28, 2008 3:41:08 午後
(1 row)

opal_app=# select job_id, to_timestamp(start_time, 'M DD, YYYY  HH24:MI:SS') from job_status where job_id='app1201563668439';
job_id | to_timestamp ------------------+------------------------
app1201563668439 | 2008-01-28 00:01:08-08
(1 row)

Or
opal_app=# select job_id,start_time from job_status where job_id='app1201565220760';
job_id | start_time ------------------+-------------------------
app1201565220760 | 1 28, 2008 4:07:00 午後
(1 row)

opal_app=# select job_id,to_timestamp(start_time, 'M DD, YYYY  HH:MI:SS') from job_status where job_id='app1201565220760';
job_id | to_timestamp ------------------+------------------------
app1201565220760 | 2008-01-28 00:07:00-08
(1 row)



Is this a bug or am I doing something wrong?


Thank you for any help,
Luca





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group