Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL or ColdFusion?: Determine length of time to take a survery

Posted on 2004-09-24
4
Medium Priority
?
232 Views
Last Modified: 2013-12-24
I am putting together a survey. I'm capturing the datetime when the person starts the survey (startDateTime) and the datetime they finish (endDateTime).

I want to be able to calculate the length of time each person took, as well as determine average time to complete.

I'm using the following code:

select Datediff(ss, startDateTime, endDateTime) as secDiff
from Survey

This will give the response in seconds which I can calulate into minutes:seconds.

Does this seem correct or is there another way that's better?

Thanks
0
Comment
Question by:akawoody
4 Comments
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 500 total points
ID: 12147498
no its very good to let SQL do most of the processing, thats how I mostly do my stuff, I mostly use cf only to display..

If you need minutes you could ofcourse immediately convert the difference to minutes, unless you also need seconds?
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 12148947
Yah! Tacobell777 is right.

It is adviceable to let SQL do the job.  Then I would suggest to use stored procedure.

So the process would be like this :

---------------------
On Your Database
---------------------
-- Create a Procedure
CREATE PROCEDURE GetTimeLength
As
Begin
  Select Datediff(ss, startDateTime, endDateTime) as secDiff
  From Survey
End

----------------------
On Your .cfm Page
----------------------
<!--- Call the Procedure using <cfstoredproc> tag --->
<cfstoredproc procedure="GetTimeLength" datasource="DSN">
  <cfprocresult name="GetRecord">
</cfstoredproc>

<!--- Display result of the procedure --->
<cfoutput query="GetRecord">
  #currentrow# - #secDiff#<br>
</cfoutput>

Hope this helps.  Just try.


Goodluck!
eNTRANCE2002 :-)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
What You Need to Know when Searching for a Webhost Provider
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question