
The DATE data type stores date and time information. The following sections describe the datetime data types and interval data types in more detail: TIMESTAMP WITH LOCAL TIME ZONE does not store time zone information internally, but you can see local time zone information in SQL output if the TZH:TZM or TZR TZD format elements are specified. TIMESTAMP WITH TIME ZONE also includes these fields: The fields that apply to all Oracle Database datetime and interval data types are: The values of these fields determine the value of the data type. Values of interval data types are sometimes called intervals.īoth datetimes and intervals are made up of fields. The interval data types are INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND. Values of datetime data types are sometimes called datetimes. SELECT * FROM SDE.The datetime data types are DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, and TIMESTAMP WITH LOCAL TIME ZONE. SELECT * FROM SDE.fuse_h WHERE DATECREATED = to_date('18/01/02', 'dd/mm/rr') Or if you have time part and you want all the record of a particular day with different time then you can do this No rows selectedThe best way to do is to pass it as a date datatype itself and not as string. Session altered.Now i run the same query and you can see the query complets successfully. SQL> alter session set nls_date_format = 'mm/dd/rr' ORA-01843: not a valid monthNow i set NLS_DATE_FORMAT as 'mm/dd/rr'

Select * from dual where sysdate = '01/13/12' SQL> select * from dual where sysdate = '01/13/12' But month range is only between 1 and 12. Session altered.Now i pass the value as '01/13/12'. SQL> alter session set nls_date_format = 'dd/mm/rr'

I have set the NLS_DATE_FORMAT as 'dd/mm/rr' Here is an example of how NLS_DATE_FORMAT works. Next, Consider the string '18/01/02' and tell me if it equal to 1 or 1? How would oracle know that? Oracle uses NLS_DATE_FORMAT parameter to implicitely identify this. So first you need to make sure if the column DATECREATED stores only the Date part or it stores both date and time. The Datatype DATE consist of two parts, Date and Time. 2 digit years went out of fashion with the millenium bug way back in the last century.īut, I've tried every combination possible!Įdited by: 933025 on 12:03 AMYou need to consider certain facts. Remember, always use 4 digit years when specifying dates. SELECT * FROM SDE.fuse_h WHERE DATECREATED between to_date('','DD/MM/YYYY') and to_date(' 23:59:59','DD/MM/YYYY HH24:MI:SS') this will allow any index to be used that exists on the datecreated column too. If time components are there you'll need to get all datecreated values for all times of that day. ORA-01843: not a valid monthThe other thing to bear in mind is that your DATECREATED column may also contain a time component in which case it might not exactly match the date, as that has an implied time of 00:00:00 SELECT * FROM SDE.fuse_h WHERE DATECREATED = '18/01/02' When I execute this statement in Oracle SQL Developer or sqlplus it does not work: and returns no records: In the table the date has a datatype of date and the value is '18/01/02'.


I'm just trying to select all records with a specific date. I'm trying to do something pretty simple in Oracle 10G, but getting really annoying as it's not working. 1.7K Training / Learning / Certification.165.3K Java EE (Java Enterprise Edition).7.8K Oracle Database Express Edition (XE).3.7K Java and JavaScript in the Database.
