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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO STORE DATE AND TIME IN A DATABASE

Status
Not open for further replies.

alexfusion

Programmer
Feb 5, 2001
94
AR
Hello everbody:
This is a short question I need to solve:
I get the date and time from now().
How can I insert this information into a table?
If I use CFINSERT I have to specify the form fields to insert.
But in the my case I get date and time using now().How can store this information so it is inserted automatically into the table every time a visitor enter to the page that will show date and time?
I hope you can help me.

Thanks a lot

alexfusion

mixale@hotmail.com
 
hi alexfusion

So you're using CFINSERT for your queries? This means all fields inserted have to be FORM variables, but FORM variables can be set on the action page too totally hidden from the user.

Remember to name the form variables the same name as the columns in the table, and just create a FORM.datetimeNow variable on the action page where 'datetimeNow' is also the name of the column you'll be inserting into.

<!--- --->
<CFSET form.datetimeNow = '#dateformat(now(),&quot;mm/dd/yyyy&quot;)# #timeformat(now(),&quot;h:m:s t&quot;)#'>

Then in your CFINSERT, if you're specifying FORMFIELDS make sure to include &quot;datetimenow&quot;. If not, everything should work fine.

<CFINSERT datasource=&quot;#ds#&quot; tablename=&quot;yourtable&quot;>

hope that i helped

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top