|
I have two date variables (Date of application, and Date of Eligibility),
and I want to compute a variable showing the difference between these two dates in days. Obviously, I can compute (EligDate - AppDate), but then how do I convert that number to "days"? Thanks, Bob Schacht Robert M. Schacht, Ph.D. <[hidden email]> Pacific Basin Rehabilitation Research & Training Center 1268 Young Street, Suite #204 Research Center, University of Hawaii Honolulu, HI 96814 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Since a date is measured in seconds, divide by 24*60*60 or use the datediff
function which takes care of things like leap days and does all the arithmetic to level of granularity you want. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob Schacht Sent: Thursday, June 26, 2008 1:44 PM To: [hidden email] Subject: Arithmetic with Time I have two date variables (Date of application, and Date of Eligibility), and I want to compute a variable showing the difference between these two dates in days. Obviously, I can compute (EligDate - AppDate), but then how do I convert that number to "days"? Thanks, Bob Schacht Robert M. Schacht, Ph.D. <[hidden email]> Pacific Basin Rehabilitation Research & Training Center 1268 Young Street, Suite #204 Research Center, University of Hawaii Honolulu, HI 96814 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Bob Schacht-3
At 03:44 PM 6/26/2008, Bob Schacht wrote:
>I have two date variables (Date of application, and Date of >Eligibility), and I want to compute a variable showing the >difference between these two dates in days. Two ways: CTIME.DAYS(EligDate - AppDate) or DATEDIFF(Appdate,Eligdate,"days") The former will include any time difference as a fractional day difference. "DATEDIFF" (SPSS 14 and later) is far more sophisticated than the CTIME.xxx() functions and I can only refer you to its documentation in the Command Syntax Reference. You can also explicitly use of SPSS's representation of dates and times as values in seconds, but I think it's less readable. Anyway, equivalent to CTIME.DAYS is (EligDate - AppDate)/(24*60*60) or (EligDate - AppDate)/86400 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Bob Schacht-3
Hi Bob,
Try the following command: COMPUTE los = CTIME.DAYS(end_date - start_date). HTH, John Norton SPSS Inc. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob Schacht Sent: Thursday, June 26, 2008 3:44 PM To: [hidden email] Subject: Arithmetic with Time I have two date variables (Date of application, and Date of Eligibility), and I want to compute a variable showing the difference between these two dates in days. Obviously, I can compute (EligDate - AppDate), but then how do I convert that number to "days"? Thanks, Bob Schacht Robert M. Schacht, Ph.D. <[hidden email]> Pacific Basin Rehabilitation Research & Training Center 1268 Young Street, Suite #204 Research Center, University of Hawaii Honolulu, HI 96814 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Richard Ristow
To which I might add that the Date and Time Wizard on the Transform menu will walk you through all these nuances and can leave you with freshly minted purpose-built syntax.
Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Thursday, June 26, 2008 2:25 PM To: [hidden email] Subject: Re: [SPSSX-L] Arithmetic with Time At 03:44 PM 6/26/2008, Bob Schacht wrote: >I have two date variables (Date of application, and Date of >Eligibility), and I want to compute a variable showing the >difference between these two dates in days. Two ways: CTIME.DAYS(EligDate - AppDate) or DATEDIFF(Appdate,Eligdate,"days") The former will include any time difference as a fractional day difference. "DATEDIFF" (SPSS 14 and later) is far more sophisticated than the CTIME.xxx() functions and I can only refer you to its documentation in the Command Syntax Reference. You can also explicitly use of SPSS's representation of dates and times as values in seconds, but I think it's less readable. Anyway, equivalent to CTIME.DAYS is (EligDate - AppDate)/(24*60*60) or (EligDate - AppDate)/86400 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Richard Ristow
At 10:25 AM 6/26/2008, Richard Ristow wrote:
>At 03:44 PM 6/26/2008, Bob Schacht wrote: > >>I have two date variables (Date of application, and Date of Eligibility), >>and I want to compute a variable showing the difference between these two >>dates in days. > >Two ways: >CTIME.DAYS(EligDate - AppDate) >or >DATEDIFF(Appdate,Eligdate,"days") > >The former will include any time difference as a fractional day difference. > >"DATEDIFF" (SPSS 14 and later) is far more sophisticated than the >CTIME.xxx() functions and I can only refer you to its documentation in the >Command Syntax Reference. Thanks to you and ViAnne for pointing to DATEDIFF. I have SPSS 16, but am more familiar with SPSS 12, which lacks this function. DateDiff is perfect for my needs. But I should have thought of CTIME.DAYS myself. Again, thanks to all for their replies. Bob Schacht >You can also explicitly use of SPSS's representation of dates and times as >values in seconds, but I think it's less readable. Anyway, equivalent to >CTIME.DAYS is >(EligDate - AppDate)/(24*60*60) >or >(EligDate - AppDate)/86400 Robert M. Schacht, Ph.D. <[hidden email]> Pacific Basin Rehabilitation Research & Training Center 1268 Young Street, Suite #204 Research Center, University of Hawaii Honolulu, HI 96814 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
