2012-02-22 3 views
2
select current_timestamp(6), current_timestamp(0) 
---------------------------------------------------- 
2012-02-22 16:03:45.988418+13 | 2012-02-22 16:03:46+13 
      -------^     ------------^ (date from the future) 

이 쿼리는 current_timestamp(0)이 "수학적으로 반올림"되어 있기 때문에 두 번째 열의 미래 타임 스탬프를 쉽게 반환 할 수 있습니다. 검색된 시간이 미래의 최대 0.5 초이기 때문에 이로 인해 예기치 않은 오류가 발생할 수 있습니다.바닥재 타임 스탬프에서 두 번째

제 질문은 - 가장 가까운 두 번째 아래로 current_timestamp(6)을 돌리는 가장 간단한 방법은 무엇입니까?

PS : 결과는 타임 스탬프 형식이 아닌 문자열

UPD을해야한다 : 나는

PPS 다시 초로 변환과 해결책을 알고

해결책

발견
select current_timestamp(6), current_timestamp(0)::abstime 

답변

3
select current_timestamp(6), date_trunc('second', current_timestamp(6)) 
관련 문제