Postgresql Database 시간함수

less than 1 minute read

http://www.postgresql.org/docs/9.1/static/functions-datetime.html

date_part(‘hour’, timestamp ‘2001-02-16 20:38:40’)

date_trunc(‘hour’, timestamp ‘2001-02-16 20:38:40’)

간단한 예제…

part는 hour만 가져온다. 값이 20이 된다.

date_trunc는 timestamp형태를 유지한다. 시간 밑으로는 절삭한다.