Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: date time

Re: date time

From: Tim X <timx_at_spamto.devnul.com>
Date: 01 Feb 2003 15:07:19 +1100
Message-ID: <87vg04r6dk.fsf@tiger.rapttech.com.au>


>>>>> "Jay" == Jay <jlee00_99_at_yahoo.com> writes:

 Jay> Hello, I am trying to query a table, but I am running into a
 Jay> problem with this simple query.  I get a error message stating
 Jay> that the month is not recognized.  Below is my SQL.  What do I
 Jay> have to do to get this simple query to run without errors?

 Jay> Select * From ServTime Where starttime between '2003-01-29  Jay> 08:00:00' and '2003-01-29 12:00:00'

Your code is relying on an implicit string to date conversion, which uses the default date formatter for the database. I think its best to avoid this if you want your code to be robust. Instead try

... between to_date('2003-01-29 12:00:00', 'YYYY-MM-DD HH24:MI:SS')

        and ...

 Jay> The values of the column starttime on the ServTime table appear  Jay> as YYYY-MM-DD HH:MM:SS

This representation is from your default date format for the DB (or maybe the format for whatever client you are using e.g. TOAD). Note that it wouldn't be MM for the minutes field as this stands for the month number - it is probably MI.

Note also that you probably want to use HH24 for the hours rather than just HH so that you can distinguish between AM/PM - otherwise you will need to include an extra field in your date formatter and your date strings indicating the am/pm of the time.

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Fri Jan 31 2003 - 22:07:19 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US