Dev./persistence

[PostgreSQL] 임의의 시간에 몇 분 더하기

인쥭 2022. 4. 27. 16:40
반응형
 

Add minutes to CURRENT_TIMESTAMP in PostgreSQL

I have a procedure in PostgreSQL that I want to add the number of minutes to CURRENT_TIMESTAMP like below timestamp_var := CURRENT_TIMESTAMP + interval '20 minutes'; But the number of minutes is a

stackoverflow.com

select current_time + (extract(minute from time '07:45:00') * interval '1 minute')
  • '07:45:00' 부분에 컬럼명을 넣어도 좋지만, 타입 캐스팅에 주의해야 한다.
    • 예시: extract(minute from CreatedAt::time) 과 같은 식으로 작성