Home » SQL & PL/SQL » SQL & PL/SQL » inserting date (oracle 10g)
inserting date [message #436969] Wed, 30 December 2009 00:17 Go to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
how to insert '30-12-2009 09:47 AM' into a oracle table column having date field should insert like that and even retrieve like that
Re: inserting date [message #436971 is a reply to message #436969] Wed, 30 December 2009 00:30 Go to previous messageGo to next message
ayush_anand
Messages: 417
Registered: November 2008
Senior Member
SQL> Create table test
  2  ( 
  3  a date
  4  );

Table created.
SQL>  ALTER SESSION SET NLS_DATE_FORMAT = 'dd-mm-yyyy hh:mi am';

Session altered.
SQL> insert into test values('30-12-2009 09:47 AM' );

1 row created.

SQL> insert into test values('30-12-2009 09:47 PM');

1 row created.

SQL> select * from test;

A
-------------------
30-12-2009 09:47 am
30-12-2009 09:47 pm
Re: inserting date [message #436972 is a reply to message #436969] Wed, 30 December 2009 00:35 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
set NLS_DATE_FORMAT for that.

regards,
Delna
Re: inserting date [message #436976 is a reply to message #436969] Wed, 30 December 2009 01:03 Go to previous messageGo to next message
prachij593
Messages: 266
Registered: May 2009
Senior Member

Not a good idea indeed! Always do the explicit conversation
Use TO_DATE and format model to insert date
and use TO_CHAR and format model to retrive the desired value
Re: inserting date [message #437186 is a reply to message #436969] Thu, 31 December 2009 14:56 Go to previous messageGo to next message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
All your posts are answered There at the documents provided to you from the beginning.This is Just to say that "No one is born genius...practice makes man perfect" Read the Documents Do some practice
Good Luck Smile

Sriram Smile
Re: inserting date [message #437204 is a reply to message #436969] Fri, 01 January 2010 01:57 Go to previous messageGo to next message
abbeytallbert
Messages: 1
Registered: December 2009
Junior Member
Use TO_DATE and format model to insert date..

By
Abbeytallbert

[Updated on: Fri, 01 January 2010 02:00] by Moderator

Report message to a moderator

Re: inserting date [message #437273 is a reply to message #436969] Sat, 02 January 2010 19:13 Go to previous messageGo to next message
wakula
Messages: 150
Registered: February 2008
Location: Poland
Senior Member
Read ISO-8601.
Use TO_DATE and always specify the date format.
Ask someone who is very far to test it (ex. if you are in US and want to load date '01/02/03' into the DB then verify if this is loaded the same way on the PC of someone from France, that it year 1002, month March, day 01... or were you thinking about 1003, week 01, day 02 or even different date format? Laughing ).
Re: inserting date [message #437297 is a reply to message #437273] Sun, 03 January 2010 07:31 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Quote:

Always do the explicit conversation
Re: inserting date [message #437298 is a reply to message #437297] Sun, 03 January 2010 07:47 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
Always do the explicit conversation

Oh well, if you really insist on that, it is conversion.

A conversation is communication by two or more people, or sometimes with oneself, often on a particular topic. Conversations are sometimes the best form of communication, since they allow people with different views of a topic to learn from each other.

Conversion is the transformation, or change, of one thing into another.
Re: inserting date [message #437312 is a reply to message #437298] Sun, 03 January 2010 13:00 Go to previous message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
aaah!!! a typo!! ....it should be "explicit conversion"

[Updated on: Sun, 03 January 2010 13:01]

Report message to a moderator

Previous Topic: How to load the data from flat file? -- urgent please
Next Topic: Is multi threading technical in pl/sql concept?
Goto Forum:
  


Current Time: Wed Dec 07 08:39:45 CST 2016

Total time taken to generate the page: 0.26207 seconds