Home » SQL & PL/SQL » SQL & PL/SQL » insert statement
insert statement [message #384403] Tue, 03 February 2009 12:03 Go to next message
dr46014
Messages: 48
Registered: February 2007
Member
I have 2 different strings stored in two variables.
X=02/03/09 11:15:15 AM
(The string is in the format MM/DD/YY HH:MI:SS AM (12hr format) )
Y=02/03/09 13:15:17
(The string is in the format MM/DD/YY HH:MI:SS (24 hr format) )

Now i need to insert it into the table of the data type
DATETIME.As the variables are strings i need to use to_date function on it and store it in database.

How can i write my insert statement in this case.
Re: insert statement [message #384404 is a reply to message #384403] Tue, 03 February 2009 12:07 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
use TO_DATE() function
Re: insert statement [message #384429 is a reply to message #384404] Tue, 03 February 2009 16:40 Go to previous messageGo to next message
pablolee
Messages: 2835
Registered: May 2007
Location: Scotland
Senior Member
BlackSwan wrote on Tue, 03 February 2009 18:07
use TO_DATE() function

I'm pretty sure that the OP knows that:
dr46014 wrote on Tue, 03 February 2009 18:03
As the variables are strings i need to use to_date function on it and store it in database.


@dr46014 how about you show us that you have put some effort in and show us what you tried?
Re: insert statement [message #384443 is a reply to message #384429] Tue, 03 February 2009 20:20 Go to previous message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
you need to use to_date with date formats.

I presume your question is how to create a "dynamic" date format based on the data given you data comes in different formats.

use CASE or DECODE to examine the date string for indicators that will tell you which date format is needed, and then return that format to your to_date function.

Good luck, Kevin
Previous Topic: Find string in view Definitition (Merged N times)
Next Topic: Autocommit after insert problem (merged)
Goto Forum:
  


Current Time: Thu Dec 08 16:42:44 CST 2016

Total time taken to generate the page: 0.05154 seconds