Problem with the to_timestamp function

Поиск
Список
Период
Сортировка
От Luca Clementi
Тема Problem with the to_timestamp function
Дата
Msg-id 47A10A1D.5020408@ucsd.edu
обсуждение исходный текст
Ответы Re: Problem with the to_timestamp function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql


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




В списке pgsql-sql по дате отправления:

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Sql ORDER BY and ASC/DESC question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Problem with the to_timestamp function