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

create date time from 2 text boxes

Guest
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

i have 2 text boxes which get submited to a action page i need to convert this to a SQL datetime so i can input it.

the format is
date form = dd/mm/yyyy
time form = hh:mm:sss

i am having trouble with the dd and mm being swoped around.
TOPICS
Advanced techniques

Views

629

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 ,
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

Use the left, mid, right, and createdate functions for the date formfield.

For the time one, are you really asking your users to type out the number of seconds?

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
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

are there any tutorials on create date left mid right?

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 ,
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

Usage is described in the cfml reference manual. If you don't have one, the internet does.

To find a tag, google <cftagname> x, where x is the cold fusion version you want. To find a function, google coldfusion function-name x. I gave you 4 functions. createdate is all one word.

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
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

ok i have worked out the issue!!

the date is converting fine now, but the time is not, only the hour is correct so if my user selects "12/02/2008" and "16:48:00"

the output is "12/02/2008" and "16:00:00"

any ideas how to get the actual whole time to convert my code is below

<CFSET smsDate = CreateDate(form.year, form.month, form.day)>
<cfset SMS_Time = '#form.SMS_Time#'>

<cfscript>
tz=createObject("component","timeZone");
hours=listFirst(SMS_Time,":")+listGetAt(SMS_Time,2,":")/60+listLast(SMS_Time,":")/360;
smsDate=dateAdd("h",hours,smsDate);
serverDate=tz.castToServer(smsDate,"Australia/Sydney");
</cfscript>

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 ,
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

There's a createdatetime function that's likely to work.

By the way, what happens if your form values are:
year = 2008
month = 6
day = 31

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
Feb 02, 2008 Feb 02, 2008

Copy link to clipboard

Copied

ok thanks Dan, that date is not valid so users woulndt be able to select it from the calendar.

createdatetime would be good just not sure where to set the time?

before the script to convert to server time?

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
Feb 04, 2008 Feb 04, 2008

Copy link to clipboard

Copied

LATEST
Hi can someone please help me with this?

i need the date and the time converting not just the date as it is now?

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