Skip to main content
Inspiring
March 11, 2014
Question

Concatenate date time and update SQL datetime field

  • March 11, 2014
  • 1 reply
  • 1271 views

I have a form that captures date and time in 2 separate fields data and time.

I need to combine these fileds and UPDATE a SQL database (datetime field)

The date field is passed like this  DSDATE={ts '2013-11-18 00:00:00'}

The time field is passed like this   TIME_IN1=14:05

How do I concatenate DSDATE AND TIME_IN1 so that I can insert like this 2013-11-18 14:05:00.000 ?

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
March 13, 2014

The easiest way may be the best. You judge.

<cfset DSDATE = parsedatetime('2013-11-18')>

<cfset  TIME_IN1="14:05">

<cfset yr = year(DSDATE)>

<cfset mnth = month(DSDATE)>

<cfset d = day(DSDATE)>

<cfset hr = listGetAt(TIME_IN1,1,":")>

<cfset mn = listGetAt(TIME_IN1,2,":")>

<cfset datetime=createdatetime(yr,mnth,d,hr,mn,0)>

<cfoutput>#datetime#</cfoutput>