sql - Issue querying date from oracle. -
i understand querying date fail comparing string date , can cause issue.
oracle 11.2 g unicode db nls_date_format dd-mon-rr
select * table q_date='16-mar-09';
it can solved
select * table trunc(q_date) = to_date('16-mar-09', 'dd-mon-yy');
what don't why works.
select* table q_date='07-jan-08';
if can please elaborate or correct mindset. thanks
oracle does allow date literals, depend on installation (particularly value of nls_date_format
explained here). hence, there not universal format interpreting single string date (unless use date
keyword).
the default format dd-mm-yy, seems format server. so, statement:
where q_date = '07-jan-08'
is interpreted using format.
i prefer use date
keyword iso standard yyyy-mm-dd format:
where q_date = date '2008-01-07'
Comments
Post a Comment