How to insert date values into table

0 votes

How do I insert into table with different  date datatype?

insert into table(id,fullname,dob)values(%id,'%name',[what should be written here?]);

I am working on oracle 10g

Feb 18, 2022 in Database by Neha
• 9,020 points
3,183 views

1 answer to this question.

0 votes

You have to convert the literal to DATE with the help of TO_DATE since DOB is DATE data type.

TO_DATE('', '<format_model>')


For example,

SQL> CREATE TABLE t(dob DATE);


Table created.

SQL> INSERT INTO table(dob) VALUES(TO_DATE('01/10/2018', 'DD/MM/YYYY'));


1 row created.

SQL> COMMIT;


Commit is complete.

SQL> SELECT * FROM table;


DOB
----------
01/10/2018
A DATE data type contains both date and time elements. If you're not concerned about the time portion, then you'll also use the ANSI Date literal which uses a hard and fast format 'YYYY-MM-DD' and is NLS independent.
For example,

SQL> INSERT INTO t(dob) VALUES(DATE '2015-12-17');

1 row created.

answered Feb 18, 2022 by Vaani
• 7,070 points

Related Questions In Database

+1 vote
1 answer

How to Insert date value in SQL table

Always use ANSI default string literal format for date i.e. YYYY-MM-DD like below. INSERT ...READ MORE

answered Feb 17, 2022 in Database by Neha
• 9,020 points
178,060 views
0 votes
0 answers

How to convert date into timestamp in SQL query?

I'm attempting to move data from the ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,000 points
1,686 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,370 points
2,317 views
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
1,424 views
0 votes
0 answers

Convert timestamp to date in Oracle SQL

How can we convert timestamp to date? READ MORE

Aug 29, 2022 in Database by Kithuzzz
• 38,000 points
916 views
0 votes
1 answer

CASE .. WHEN expression in Oracle SQL

Use an IN clause. Example: SELECT status, CASE ...READ MORE

answered Sep 17, 2022 in Database by narikkadan
• 63,600 points
610 views
0 votes
1 answer

How to find top three highest salary in emp table in oracle?

Use this: SELECT *FROM ...READ MORE

answered Sep 18, 2022 in Database by narikkadan
• 63,600 points
9,136 views
0 votes
1 answer

Automating Oracle script with nolio

Depending upon the details of your script ...READ MORE

answered Jul 17, 2018 in Other DevOps Questions by ajs3033
• 7,300 points
1,048 views
0 votes
1 answer

How to calculate age (in years) based on Date of Birth and getDate()

Following can be a solution to your ...READ MORE

answered Feb 23, 2022 in Database by Vaani
• 7,070 points
1,591 views
0 votes
1 answer

How to take user input in livesql.oracle.com in PLSQL?

To create a procedure with a parameter ...READ MORE

answered Feb 7, 2022 in Database by Vaani
• 7,070 points
4,241 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP