본문 바로가기

Database Architecture/postgresql

데이터 타입

반응형

1. 데이터 타입 확인하기

 - select pg_typeof(변수명)

2. 날짜 계산 (분단위 계산)

select updatedate  from valueindex
where updatedate > now() - '1 minutes'::interval
limit 5

3. 날짜 order by 주의사항

character형태로 되어있는 날짜를 order by 할때 to_date(p.dates,'YYYY-MM-DD')로 하면 안먹힌다. to_date(p.dates,'yyyy-MM-dd')로 해야한다.

 

아래와 같이 사용한다.

select c.companyname,p.수정주가, to_date(p.dates,'YYYY-MM-DD')
from periodpriceg p,companyg c
where 1=1
and p.code = c.code
and p.code ='A011330'
order by to_date(p.dates,'yyyy-MM-dd')

반응형