I have an insert query:
INSERT INTO THE_TABLE (Field_A)
VALUES (TO_DATE('08/12/2011 08:35:42 AM','HH:MI:SS PM'))
WHERE Something = 'SomethingElse'
Field_A is a Date field. When I execute the query, Field_A still shows a date and time.
Is there a way to grab only the time?
I have tried To_Char(), but then it converts to a string and the field wont take it.
I have also tried TO_DATE(’08:35:42 AM’,’HH:MI:SS PM’) and that doesn’t work either, it still shows a date and time in the table.
If your field is a date field, you will always have the date portion of your date time.
You could store it as something else, like just the number of seconds and use a conversion function to convert it to a time. Since it seems like
TO_CHARwon’t take a number and convert it a time, you’d have to do this on the application side.So I’d just store it as a
DATEanyways to avoid confusion; just ignore the date portion when using it.And by the way, this:
Is not quite right, because strings in the correct format are implicitly converted to
DATEs.