time calculation

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

time calculation

Mohammed Mustafa

Dear list

 

I have to variables among a dataset

One is for the interview start time “STM”

The other is for the interview end time “ETM”

The time format is entered as 4 digits – 24 hours format

I need to calculate the interview duration IN MINUTES based on the start and end time, and the results to be in a new variable “DUR”

 

I tried the time/date wizard in IBM SPSS 19 but I couldn’t find options for timing there

 

Thanks in advance

 

Mohd

Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Bruce Weaver
Administrator
You say, "The time format is entered as 4 digits - 24 hours format."  I can't tell from that what formats are used for STM and ETM.  I.e., are they formatted as TIME5, F4.0, N4.0, A4, or something else?  What does it say in the Type and Width columns in the Variable View window of the data file?


Mohammed Mustafa wrote
Dear list



I have to variables among a dataset

One is for the interview start time "STM"

The other is for the interview end time "ETM"

The time format is entered as 4 digits - 24 hours format

I need to calculate the interview duration IN MINUTES based on the start and
end time, and the results to be in a new variable "DUR"



I tried the time/date wizard in IBM SPSS 19 but I couldn't find options for
timing there



Thanks in advance



Mohd
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Maguin, Eugene
In reply to this post by Mohammed Mustafa
Mohd,
 
Are STM and ETM time formatted variables, i.e., Time5 or Time8?  I think you should be able to do a simple subtraction:
compute dur=etm-stm. Do you format dur as Time5 or Time8?
 
But are there instances were stm is the next day?
 
I get it that you are having trouble, but what kind of trouble are you having. I can get the wizard to do what i think you want it to do.
 
Gene Maguin
 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mohd Aayed
Sent: Wednesday, April 20, 2011 7:21 AM
To: [hidden email]
Subject: time calculation

Dear list

 

I have to variables among a dataset

One is for the interview start time “STM”

The other is for the interview end time “ETM”

The time format is entered as 4 digits – 24 hours format

I need to calculate the interview duration IN MINUTES based on the start and end time, and the results to be in a new variable “DUR”

 

I tried the time/date wizard in IBM SPSS 19 but I couldn’t find options for timing there

 

Thanks in advance

 

Mohd

Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Mohammed Mustafa
In reply to this post by Bruce Weaver
For example

If the interview started at 4 pm and ended at 5:10 pm then the start time
variable 'STM' = 1600 and the end time variable 'ETM' = 1710
My question is how to calculate the time duration between the start time STM
and the end time ETM and to put the results in a new variable for duration
'DUR'

Hope its more clear now

Thanks
MOhd
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Wednesday, April 20, 2011 04:11 PM
To: [hidden email]
Subject: Re: time calculation

You say, "The time format is entered as 4 digits - 24 hours format."  I
can't tell from that what formats are used for STM and ETM.  I.e., are they
formatted as TIME5, F4.0, N4.0, A4, or something else?  What does it say in
the Type and Width columns in the Variable View window of the data file?



Mohammed Mustafa wrote:

>
> Dear list
>
>
>
> I have to variables among a dataset
>
> One is for the interview start time "STM"
>
> The other is for the interview end time "ETM"
>
> The time format is entered as 4 digits - 24 hours format
>
> I need to calculate the interview duration IN MINUTES based on the
> start and end time, and the results to be in a new variable "DUR"
>
>
>
> I tried the time/date wizard in IBM SPSS 19 but I couldn't find
> options for timing there
>
>
>
> Thanks in advance
>
>
>
> Mohd
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/time-calculation-tp4315535p431
5795.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Mohammed Mustafa
In reply to this post by Maguin, Eugene

Thank you Gene

 

For example

 

If the interview started at 4 pm and ended at 5:10 pm then the start time variable 'STM' = 1600 and the end time variable 'ETM' = 1710 My question is how to calculate the time duration between the start time STM and the end time ETM and to put the results in a new variable for duration 'DUR'

 

Hope its more clear now

 

Regards,

Mohd

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Wednesday, April 20, 2011 04:46 PM
To: [hidden email]
Subject: Re: time calculation

 

Mohd,

 

Are STM and ETM time formatted variables, i.e., Time5 or Time8?  I think you should be able to do a simple subtraction:

compute dur=etm-stm. Do you format dur as Time5 or Time8?

 

But are there instances were stm is the next day?

 

I get it that you are having trouble, but what kind of trouble are you having. I can get the wizard to do what i think you want it to do.

 

Gene Maguin

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mohd Aayed
Sent: Wednesday, April 20, 2011 7:21 AM
To: [hidden email]
Subject: time calculation

Dear list

 

I have to variables among a dataset

One is for the interview start time “STM”

The other is for the interview end time “ETM”

The time format is entered as 4 digits – 24 hours format

I need to calculate the interview duration IN MINUTES based on the start and end time, and the results to be in a new variable “DUR”

 

I tried the time/date wizard in IBM SPSS 19 but I couldn’t find options for timing there

 

Thanks in advance

 

Mohd

Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Bruce Weaver
Administrator
You've still not told us whether STM and ETM are formatted as numeric or string.  Here are two demos, the first for numeric variables, the second for string.  Both assume you have no cases where STM and ETM are on different days (e.g., STM shortly before midnight and ETM shortly after).  

* Demo 1:  Assumes STM and ETM are NUMERIC variables.
data list list / STM ETM (2f4.0) .
begin data.
900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = trunc(STM/100).
compute #m = STM - #h*100.
compute STM_time = time.hms(#h,#m,0).

compute #h = trunc(ETM/100).
compute #m = ETM - #h*100.
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.

* -------------------------------------------------- .

* Demo 2:  Assumes STM and ETM are STRING variables with leading zeros.
data list list / STM ETM (2A4) .
begin data.
0900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = number(substr(STM,1,2),f2).
compute #m = number(substr(STM,3,2),f2).
compute STM_time = time.hms(#h,#m,0).

compute #h = number(substr(ETM,1,2),f2).
compute #m = number(substr(ETM,3,2),f2).
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.


Mohammed Mustafa wrote
Thank you Gene



For example



If the interview started at 4 pm and ended at 5:10 pm then the start time
variable 'STM' = 1600 and the end time variable 'ETM' = 1710 My question is
how to calculate the time duration between the start time STM and the end
time ETM and to put the results in a new variable for duration 'DUR'



Hope its more clear now



Regards,

Mohd





From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Wednesday, April 20, 2011 04:46 PM
To: [hidden email]
Subject: Re: time calculation



Mohd,



Are STM and ETM time formatted variables, i.e., Time5 or Time8?  I think you
should be able to do a simple subtraction:

compute dur=etm-stm. Do you format dur as Time5 or Time8?



But are there instances were stm is the next day?



I get it that you are having trouble, but what kind of trouble are you
having. I can get the wizard to do what i think you want it to do.



Gene Maguin





  _____

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Mohd Aayed
Sent: Wednesday, April 20, 2011 7:21 AM
To: [hidden email]
Subject: time calculation

Dear list



I have to variables among a dataset

One is for the interview start time "STM"

The other is for the interview end time "ETM"

The time format is entered as 4 digits - 24 hours format

I need to calculate the interview duration IN MINUTES based on the start and
end time, and the results to be in a new variable "DUR"



I tried the time/date wizard in IBM SPSS 19 but I couldn't find options for
timing there



Thanks in advance



Mohd
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Automatic reply: time calculation

Genevieve Odoom
Hello,

Thank you for your email. I will be on maternity leave beginning Monday January 17th, returning on  Monday, January 16th 2012. In my absence, please contact Valerie Villela, Policy and Program Analyst at [hidden email] and via telephone at 905-851-8821 X241 or Dan Buchanan, Director, Financial Policy at [hidden email] or via telephone at 905-851-8821 X229.


Thanks!
Genevieve Odoom
Policy and Program Analyst
OANHSS
Suite 700 - 7050 Weston Rd. Woodbridge,
ON L4L 8G7
Tel: (905) 851-8821 x 241 Fax: (905) 851-0744
[hidden email]
www.oanhss.org<https://mail.oanhss.org/ecp/Organize/www.oanhss.org>

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Mohammed Mustafa
In reply to this post by Bruce Weaver
Thank you Bruce

The variable is numeric
And both start time and end time are in the same day
As the interview duration is maximum 120 minutes
I'll try your method and let you know if it works
Although I see it's a bit complicated

Thanks
Mohd

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Wednesday, April 20, 2011 06:50 PM
To: [hidden email]
Subject: Re: time calculation

You've still not told us whether STM and ETM are formatted as numeric or
string.  Here are two demos, the first for numeric variables, the second for
string.  Both assume you have no cases where STM and ETM are on different
days (e.g., STM shortly before midnight and ETM shortly after).

* Demo 1:  Assumes STM and ETM are NUMERIC variables.
data list list / STM ETM (2f4.0) .
begin data.
900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = trunc(STM/100).
compute #m = STM - #h*100.
compute STM_time = time.hms(#h,#m,0).

compute #h = trunc(ETM/100).
compute #m = ETM - #h*100.
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.

* -------------------------------------------------- .

* Demo 2:  Assumes STM and ETM are STRING variables with leading zeros.
data list list / STM ETM (2A4) .
begin data.
0900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = number(substr(STM,1,2),f2).
compute #m = number(substr(STM,3,2),f2).
compute STM_time = time.hms(#h,#m,0).

compute #h = number(substr(ETM,1,2),f2).
compute #m = number(substr(ETM,3,2),f2).
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.



Mohammed Mustafa wrote:

>
> Thank you Gene
>
>
>
> For example
>
>
>
> If the interview started at 4 pm and ended at 5:10 pm then the start
> time variable 'STM' = 1600 and the end time variable 'ETM' = 1710 My
> question is how to calculate the time duration between the start time
> STM and the end time ETM and to put the results in a new variable for
> duration 'DUR'
>
>
>
> Hope its more clear now
>
>
>
> Regards,
>
> Mohd
>
>
>
>
>
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Gene Maguin
> Sent: Wednesday, April 20, 2011 04:46 PM
> To: [hidden email]
> Subject: Re: time calculation
>
>
>
> Mohd,
>
>
>
> Are STM and ETM time formatted variables, i.e., Time5 or Time8?  I
> think you should be able to do a simple subtraction:
>
> compute dur=etm-stm. Do you format dur as Time5 or Time8?
>
>
>
> But are there instances were stm is the next day?
>
>
>
> I get it that you are having trouble, but what kind of trouble are you
> having. I can get the wizard to do what i think you want it to do.
>
>
>
> Gene Maguin
>
>
>
>
>
>   _____
>
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Mohd Aayed
> Sent: Wednesday, April 20, 2011 7:21 AM
> To: [hidden email]
> Subject: time calculation
>
> Dear list
>
>
>
> I have to variables among a dataset
>
> One is for the interview start time "STM"
>
> The other is for the interview end time "ETM"
>
> The time format is entered as 4 digits - 24 hours format
>
> I need to calculate the interview duration IN MINUTES based on the
> start and end time, and the results to be in a new variable "DUR"
>
>
>
> I tried the time/date wizard in IBM SPSS 19 but I couldn't find
> options for timing there
>
>
>
> Thanks in advance
>
>
>
> Mohd
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/time-calculation-tp4315535p432
8441.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: time calculation

Bruce Weaver
Administrator
Complication is in the eye of the beholder, I guess.  ;-)


Mohammed Mustafa wrote
Thank you Bruce

The variable is numeric
And both start time and end time are in the same day
As the interview duration is maximum 120 minutes
I'll try your method and let you know if it works
Although I see it's a bit complicated

Thanks
Mohd

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Wednesday, April 20, 2011 06:50 PM
To: [hidden email]
Subject: Re: time calculation

You've still not told us whether STM and ETM are formatted as numeric or
string.  Here are two demos, the first for numeric variables, the second for
string.  Both assume you have no cases where STM and ETM are on different
days (e.g., STM shortly before midnight and ETM shortly after).

* Demo 1:  Assumes STM and ETM are NUMERIC variables.
data list list / STM ETM (2f4.0) .
begin data.
900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = trunc(STM/100).
compute #m = STM - #h*100.
compute STM_time = time.hms(#h,#m,0).

compute #h = trunc(ETM/100).
compute #m = ETM - #h*100.
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.

* -------------------------------------------------- .

* Demo 2:  Assumes STM and ETM are STRING variables with leading zeros.
data list list / STM ETM (2A4) .
begin data.
0900 1002
1600 1710
end data.

numeric STM_time ETM_time (time5) / ET_minutes (f5.0).

compute #h = number(substr(STM,1,2),f2).
compute #m = number(substr(STM,3,2),f2).
compute STM_time = time.hms(#h,#m,0).

compute #h = number(substr(ETM,1,2),f2).
compute #m = number(substr(ETM,3,2),f2).
compute ETM_time = time.hms(#h,#m,0).

compute ET_minutes = ctime.minutes(ETM_time - STM_time).

list.



Mohammed Mustafa wrote:
>
> Thank you Gene
>
>
>
> For example
>
>
>
> If the interview started at 4 pm and ended at 5:10 pm then the start
> time variable 'STM' = 1600 and the end time variable 'ETM' = 1710 My
> question is how to calculate the time duration between the start time
> STM and the end time ETM and to put the results in a new variable for
> duration 'DUR'
>
>
>
> Hope its more clear now
>
>
>
> Regards,
>
> Mohd
>
>
>
>
>
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Gene Maguin
> Sent: Wednesday, April 20, 2011 04:46 PM
> To: [hidden email]
> Subject: Re: time calculation
>
>
>
> Mohd,
>
>
>
> Are STM and ETM time formatted variables, i.e., Time5 or Time8?  I
> think you should be able to do a simple subtraction:
>
> compute dur=etm-stm. Do you format dur as Time5 or Time8?
>
>
>
> But are there instances were stm is the next day?
>
>
>
> I get it that you are having trouble, but what kind of trouble are you
> having. I can get the wizard to do what i think you want it to do.
>
>
>
> Gene Maguin
>
>
>
>
>
>   _____
>
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Mohd Aayed
> Sent: Wednesday, April 20, 2011 7:21 AM
> To: [hidden email]
> Subject: time calculation
>
> Dear list
>
>
>
> I have to variables among a dataset
>
> One is for the interview start time "STM"
>
> The other is for the interview end time "ETM"
>
> The time format is entered as 4 digits - 24 hours format
>
> I need to calculate the interview duration IN MINUTES based on the
> start and end time, and the results to be in a new variable "DUR"
>
>
>
> I tried the time/date wizard in IBM SPSS 19 but I couldn't find
> options for timing there
>
>
>
> Thanks in advance
>
>
>
> Mohd
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/time-calculation-tp4315535p432
8441.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).