Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFQUERY Insert Date & Time

Status
Not open for further replies.

Nomad2

Programmer
Aug 30, 2002
9
0
0
US
I would like to insert the data and time into the date/time field. If not defined, it usually defined the date only.

How do I put the time in as well. I am using Oracle database, but I would like to enter the date and time specified by Coldfusion.

<cfset todate = now()> <!--- holds the time and date --->

<cfquery name=&quot;newRecord&quot; datasource=&quot;db&quot;>
insert into transaction(id,desc,postdate)
values (1,'Book','#now()#')
</cfquery>


How do i insert the time as well


 
I think you have to change:

values (1,'Book','#now()#')

to:
values (1,'Book','#todate#')

because you used <CFSET todate = now()>
so the date and time are being stored as todate

Hope this helps,
-NeoTurtle

 
Hi!

I am not an Oracle Expert but when using ACCESS AND SQL server I would do this to solve your problem:

<cfquery name=&quot;newRecord&quot; datasource=&quot;db&quot;>
insert into transaction(id,desc,postdate)
values (1,'Book',#CreateODBCDateTime(now())#)
</cfquery>

This would add the date and time in the db... Not sure it works with Oracle thought...

Try it!
Chris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top