Unix Technical Forum

Re: Detecting the INSERT format for DATE database fields?

This is a discussion on Re: Detecting the INSERT format for DATE database fields? within the Oracle Database forums, part of the Database Server Software category; --> "Thomas Jerkins" <tomjerk@hotmail.com> a écrit dans le message de news:cst3bg$osr$05$1@news.t-online.com... | Assume I got a database resp. table defintion ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 10:27 AM
Michel Cadot
 
Posts: n/a
Default Re: Detecting the INSERT format for DATE database fields?


"Thomas Jerkins" <tomjerk@hotmail.com> a écrit dans le message de
news:cst3bg$osr$05$1@news.t-online.com...
| Assume I got a database resp. table defintion with a DATE field. How do I find out in which format
the
| field should be filled in an INSERT SQL statement?
|
| Sometimes when I enter e.g.
|
| INSERT INTO .... VALUES (....., '2005-01-25',.....);
| or
| INSERT INTO .... VALUES (....., '2005-01-25-13.14.15.00',.......);
|
| I got an error like:
|
| ORA-01861: literal does not match format string
|
| before I realized that
|
| INSERT INTO .... VALUES (....., '25-01-2005',....);
|
| is the correct format.
|
| Tom
|

Never rely on implicit conversion.
Use to_date to explicitly convert your external format to date datatype:
insert into ... values (..., to_date('2005-01-25','YYYY-MM-DD'),...);
or
insert into ... values (..., to_date('2005-01-25-13.14.15.00','YYYY-MM-DD-HH24.MI.SS.FF2'),...);
or whatever is your external format.
This is the correct way.

Regards
Michel Cadot


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:09 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com