|
Hi folks,
I am constructing an SPSS database and will need to be able to subtract response times to get time interval data. Will I need to use the format "DD/MM/YYYY hh:mm" if I want to subtract e.g. Response Time x (23:55) from Response Time y (00:04). The correct answer is 9 minutes (nothing wrong with my maths as you can see) so I don't want to end up with an answer or 23hrs 1min. My only concern with using "DD/MM/YYYY hh:mm" is the potential for data entry error, but am I right to assume that using this date/time format is the best way to ensure correct subtraction calculations???? |
|
Use the DATEDIFF function to subtract times....
The DATEDIFF function calculates the difference between two date values and returns an integer (with any fraction component truncated) in the specified date/time units. The general form of the expression is: DATEDIFF(datetime2, datetime1, "unit"). where datetime2 and datetime1 are both date or time format variables (or numeric values that represent valid date/time values), and "unit" is one of the following string literal values, enclosed in quotes: Years Quarters Months Weeks Days Hours Minutes <------------I believe this is the one you want. Seconds So it would look something like this... Compute RTinterval=DATEDIFF(RTy, RTx, MINUTES). Melissa -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of smasterson Sent: Monday, October 08, 2007 8:24 AM To: [hidden email] Subject: [SPSSX-L] Subtracting times - what date format is needed Hi folks, I am constructing an SPSS database and will need to be able to subtract response times to get time interval data. Will I need to use the format "DD/MM/YYYY hh:mm" if I want to subtract e.g. Response Time x (23:55) from Response Time y (00:04). The correct answer is 9 minutes (nothing wrong with my maths as you can see) so I don't want to end up with an answer or 23hrs 1min. My only concern with using "DD/MM/YYYY hh:mm" is the potential for data entry error, but am I right to assume that using this date/time format is the best way to ensure correct subtraction calculations???? -- View this message in context: http://www.nabble.com/Subtracting-times---what-date-format-is-needed-tf4 587668.html#a13095031 Sent from the SPSSX Discussion mailing list archive at Nabble.com. PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. |
|
In reply to this post by smasterson
At 09:24 AM 10/8/2007, smasterson wrote:
>I am constructing an SPSS database and will need to be able to >subtract response times to get time interval data. Will I need to use >the format "DD/MM/YYYY hh:mm" if I want to subtract e.g. Response Time >x (23:55) from Response Time y (00:04). The correct answer is 9 >minutes (nothing wrong with my maths as you can see) so I don't want >to end up with an answer or 23hrs 1min. My only concern with using >"DD/MM/YYYY hh:mm" is the potential for data entry error, but am I >right to assume that using this date/time format is the best way to >ensure correct subtraction calculations???? No, I'm afraid you're not. But the actual situation is more favorable than you'd anticipate. You should have your data-entry people enter the dates in whatever format is most convenient and error-free. You'll read those as *character* values. However (and this is a very strong recommendation), your program that reads the data should immediately calculate separate variables that give the values in SPSS date-time representation. There are SPSS date and date-time formats to read most common date representations; use them with the NUMBER function, since SPSS dates are numeric variables. If you don't have a format that SPSS will read, you can convert it with string commands. Then, give the new variables any SPSS date or date-time format you want. The formats affect only the *display* of these variables, not their underlying values(*). As Melissa Ives wrote, you can then use DATEDIFF. Or, simply subtract the values; the difference of two SPSS date or date-time variables are in seconds. (*) "Internally, all date format variables are stored as the number of seconds from 0 hours, 0 minutes, and 0 seconds of Oct. 14, 1582." - SPSS 15 Command Syntax Reference, p. 47. |
|
Thank you Richard,
As you have no doubt surmised, I am a novice at data analysis on SPSS so am learning as I go Kind regards Siobhan Siobhan Masterson Project Manager - OHCAR Department of Public Health Medicine HSE - West Old St. Eunan's Ward St. Conal's Hospital Letterkenny Co. Donegal Ireland Office: 00 353 74 9104460 (main office) x4076 Mobile: 00 353 87 2773912 Richard Ristow <wrristow@mindspr ing.com> To smasterson 08/10/2007 20:10 <[hidden email]>, [hidden email] cc Melissa Ives <[hidden email]> Subject Re: Subtracting times - what date format is needed At 09:24 AM 10/8/2007, smasterson wrote: >I am constructing an SPSS database and will need to be able to >subtract response times to get time interval data. Will I need to use >the format "DD/MM/YYYY hh:mm" if I want to subtract e.g. Response Time >x (23:55) from Response Time y (00:04). The correct answer is 9 >minutes (nothing wrong with my maths as you can see) so I don't want >to end up with an answer or 23hrs 1min. My only concern with using >"DD/MM/YYYY hh:mm" is the potential for data entry error, but am I >right to assume that using this date/time format is the best way to >ensure correct subtraction calculations???? No, I'm afraid you're not. But the actual situation is more favorable than you'd anticipate. You should have your data-entry people enter the dates in whatever format is most convenient and error-free. You'll read those as *character* values. However (and this is a very strong recommendation), your program that reads the data should immediately calculate separate variables that give the values in SPSS date-time representation. There are SPSS date and date-time formats to read most common date representations; use them with the NUMBER function, since SPSS dates are numeric variables. If you don't have a format that SPSS will read, you can convert it with string commands. Then, give the new variables any SPSS date or date-time format you want. The formats affect only the *display* of these variables, not their underlying values(*). As Melissa Ives wrote, you can then use DATEDIFF. Or, simply subtract the values; the difference of two SPSS date or date-time variables are in seconds. (*) "Internally, all date format variables are stored as the number of seconds from 0 hours, 0 minutes, and 0 seconds of Oct. 14, 1582." - SPSS 15 Command Syntax Reference, p. 47. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.clearswift.com ********************************************************************** |
| Free forum by Nabble | Edit this page |
