Solved

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

Posted on 2004-09-24
4
159 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 125 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now