Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-24
4
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

715 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