Oracle SQL - DATE greater than statement -


as title says, want find way check of data sets past 6 months sysdate via query.

select * orderarchive orderdate <= '31 dec 2014'; 

i've tried following returns error saying date format wrong. however, inserting data used date format requested/intended , had no issues.

error @ command line : 10 column : 25

blockquote

error report -

sql error: ora-01861: literal not match format string 01861. 00000 - "literal not match format string"

*cause: literals in input must same length literals in format string (with exception of leading whitespace). if "fx" modifier has been toggled on, literal must match exactly, no whitespace.

*action: correct format string match literal.

as query string literal, , assuming dates stored date should use date literals:

select * orderarchive orderdate <= date '2015-12-31' 

if want use to_date (because, example, query value not literal), suggest explicitly set nls_date_language parameter using abbreviated month names. way, won't break on localized oracle installation:

select * orderarchive orderdate <= to_date('31 dec 2014', 'dd mon yyyy',                            'nls_date_language = american'); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -