• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

upload into datetime

Guest
May 18, 2007 May 18, 2007

Copy link to clipboard

Copied

Hi i have an csv file which i have a date time column which i need to upload to mysql database column with is formatted as datetime

the problem i have is the csv is formatting the date time as mm-dd-yyyy hh:mm:ss which will not upload

i have tried uploaing via a http request, is there a way of changing the format in th csv or adding some cf code to change the format after the http request

the http code i am using is

<cfloop index="currRow" from="#form.startRow#" to="#form.dispRows#">
<cfif IsDefined("form.ID_#currRow#")>
<cfset ID = Evaluate("form.ID_" & currRow)>


<cfquery name="INSERT" datasource="#application.ds#">
UPDATE records
SET Dateoh = '#form["DateofSM_#currRow#"]#'
WHERE ID = #ID#
</cfquery>


<cfelse>
<cfbreak>
</cfif>
</cfloop>
TOPICS
Advanced techniques

Views

243

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 19, 2007 May 19, 2007
Probably not but you can try it. Dateformat returns a string, not a datetime object. CreateDateTime will create a datetime object but you have to use it the way the manual tells you to. From then, either createodbcdatetime or cfqueryparam will work.

Votes

Translate

Translate
LEGEND ,
May 19, 2007 May 19, 2007

Copy link to clipboard

Copied

Use the necessary cold fusion functions to convert the string into an odbc datetime object before you talk to your db.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2007 May 19, 2007

Copy link to clipboard

Copied

ok thanks,

can i just do a cfset with

#DateFormat(CreateDateTime(form["DateofSM_#currRow#"]))#

would this work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2007 May 19, 2007

Copy link to clipboard

Copied

LATEST
Probably not but you can try it. Dateformat returns a string, not a datetime object. CreateDateTime will create a datetime object but you have to use it the way the manual tells you to. From then, either createodbcdatetime or cfqueryparam will work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation