Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date query 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
Hi all,
I am looking to do a query that retrieves the dates in a table that are todays date.

I tried this

select date_time, refnum from inventory where date_time > to_date('17-FEB-02, 12:00:00')
*
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string

I dont think I am handling the date input correctly. Any idea how to do the comparison please?

Rgds
Matt
 
select date_time, refnum
from inventory
where date_time > to_date('17-FEB-2002', 'DD-MON-YYYY')

also:

select date_time, refnum
from inventory
where date_time >= trunc(sysdate)
 
I made an error in the first statement, you'd need to change the ">" to ">=".
 
Your specific problem is that Oracle is using the default date format in the to_date function and this default is not compatible with the date string you are trying to convert. To correct this you need to supply an explicit date format, as sfvb suggests. Try something like

select date_time, refnum from inventory where date_time > to_date('17-FEB-02 12:00:00', 'dd-mon-yy hh24:mi:ss')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top