Re: [EpiData-list] Entering time and date for outbreaks
Hi Charity
I have tried adapting that check code to my file, just changing the field names as necessary, and it worked perfectly. How exciting to see my incubation times popping up effortlessly! Thanks very much for that.
Christine
Christine Roseveare Analyst Regional Public Health 570 9194 027 495 9671
epidata-list@lists.umanitoba.ca 27/02/2007 12:24 p.m. >>>
Hi Christine,
I think I forgot to mention that for vhours to be a field it needs to be fairly large as the number of hours since 1899 is a big number. Also it needs to have two decimal places. I used a nine digit number plus two decimals when I tried it.
Once you know you have it working you could calculate the difference directly into the timediff field (which also needs two decimal places but does not need to be nearly as large) without having to store it in vhours1 and vhours2 first, to save having meaningless numbers lying about.
Also, I didn't use the word "LET" - not sure if this makes any difference. And the number will not calculate until all the fields in the formula are filled, i.e. if you put the code in the time field but do not yet have anything in the date field, it will not work. I put the full calculation in all fields so that any time a field was updated the difference would update also.
I will paste what I did below and hopefully it will clear anything else up I've forgotten to mention! Let me know how you go.
Thanks, Charity
Below is the text from the qes file I used to test my formulae.
vtime1 ##.## vdate1 <dd/mm/yyyy>
vhours1 #########.##
vtime2 ##.## vdate2 <dd/mm/yyyy>
vhours2 #########.##
timediff ####.##
And the code I used in my chk file (for the second time and date only, to save space):
vtime2 MUSTENTER AFTER ENTRY IF (vtime2 < 0) OR (vtime2 > 23.59) OR (Frac(vtime2) > 0.59) THEN HELP "Enter a valid time" GOTO vtime2 ENDIF vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24) timediff=vhours2-vhours1 END END
vdate2 MUSTENTER AFTER ENTRY vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24) timediff=vhours2-vhours1 END END
vhours2 NOENTER END Charity Jenkins Data Processing Officer Centre for Behavioural Research in Cancer The Cancer Council Victoria http://www.cancervic.org.au/cbrchttps://webmail.accv.org.au/exchweb/bin/redir.asp?URL=http://www.cancervic.org.au/cbrc
On 2/27/07, epidata-list@lists.umanitoba.ca <epidata-list@lists.umanitoba.ca
wrote:
Hi Charity
Thanks very much for your formula. Its sounds really good. I had a
go
at putting it in a check file. Following through your example below 'Diatime' is my 'vtime2' and 'diadate' is my vdate2. I thought I
would
start off slowly by seeing if I coudl calculate Vhours2. I created a
new
field called Vhours2 in my rec file and then I put the following
code
into the check file.
DIATIME AFTER ENTRY LET VHOURS2=INT(DIATIME)+(FRAC(DIATIME)/0.6)+(DIADATE*24) END END
Epi accepted the code but nothing appears in the vhours2 field when
I
enter information in the diadate and diatime fields. Can you see what
I
am doing wrong?
thanks
Christine Roseveare Analyst Regional Public Health 570 9194 027 495 9671
participants (1)
-
epidata-list@lists.umanitoba.ca