Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to insert a date value without time into oracle table so as to sort by date.
Thanks in advance
Asok
Posted
Updated 5-Sep-11 0:20am
v2

There is no Date only data type.
You can insert it as
SQL
Insert into yourtable values(to_date('05/09/2011','dd/mm/yyyy'));

or you can select as
SQL
Select to_char(yourdate, 'dd/mm/yyyy') from yourtable;
 
Share this answer
 
When inserting the data if you want to set time portion to midnight, you can use TRUNC. For example, to add current date at midnight:
SQL
INSERT INTO TableName (DateColumnName) VALUES (TRUNC(SYSDATE));

As Prerak also pointed out you can handle the time portion also when selecting the data. For example:
SQL
SELECT TRUNC(DateColumnName)
FROM TableName
WHERE TRUNC(DateColumnName) < SYSDATE 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900