Week Variable

I would like to create a variable that defines certain weeks. Community
health workers in the program do an active sweep of their village to seek
out patients every week. I would like to create a variable that defines
what week of the program the data gathering occurred in. I would also like
to create a variable that defines the epidemiological week of data
collection. How do I do this? I tried to do some math with the dates but I
couldn’t make it work.This is what I wrote:

if(double(today)>=16621 and double(today)<=16627,“Ratissage
1”,if(double(today)>=16628 and double(today)<=16634,“Ratissage
2”,if(double(today)>=16635 and double(today)<=16641,“Ratissage
3”,if(double(today)>=16642 and double(today)<=16648,“Ratissage
4”,if(double(today)>=16649 and double(today)<=16655,“Ratissage 5”,“Pas
Commencer”)))))

Sarah,

If you know the date that the enrollment started, the easiest thing to do
is likely to make a computed string to capture this.

You can use a hidden value to calculate the week post enrollment (I’m
pretending that ‘2015-06-05’ is the “start date” here, you can either use a
different date or collect this somewhere else)

week_of_program = int((today() - date(“2014-06-05”)) div 7)

and then use a string join to actually get the displayable week (this will
round down, so week 1.3 = week 1, you can move the start date 7 days back
to make the ‘first’ week week 1 instead of week 0)

week_of_program_display = concat("Ratissage ", /data/week_of_program)

Does that seem like it would work with your use case?

-Clayton

··· On Thu, Jun 4, 2015 at 11:36 AM, Sarah Mollenkopf wrote:

I would like to create a variable that defines certain weeks. Community
health workers in the program do an active sweep of their village to seek
out patients every week. I would like to create a variable that defines
what week of the program the data gathering occurred in. I would also like
to create a variable that defines the epidemiological week of data
collection. How do I do this? I tried to do some math with the dates but I
couldn’t make it work.This is what I wrote:

if(double(today)>=16621 and double(today)<=16627,“Ratissage
1”,if(double(today)>=16628 and double(today)<=16634,“Ratissage
2”,if(double(today)>=16635 and double(today)<=16641,“Ratissage
3”,if(double(today)>=16642 and double(today)<=16648,“Ratissage
4”,if(double(today)>=16649 and double(today)<=16655,“Ratissage 5”,“Pas
Commencer”)))))


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yes, it does! I will try it out! Thank you for the prompt response!

··· On Thu, Jun 4, 2015 at 4:16 PM, Clayton Sims wrote:

Sarah,

If you know the date that the enrollment started, the easiest thing to do
is likely to make a computed string to capture this.

You can use a hidden value to calculate the week post enrollment (I’m
pretending that ‘2015-06-05’ is the “start date” here, you can either use a
different date or collect this somewhere else)

week_of_program = int((today() - date(“2014-06-05”)) div 7)

and then use a string join to actually get the displayable week (this will
round down, so week 1.3 = week 1, you can move the start date 7 days back
to make the ‘first’ week week 1 instead of week 0)

week_of_program_display = concat("Ratissage ", /data/week_of_program)

Does that seem like it would work with your use case?

-Clayton

On Thu, Jun 4, 2015 at 11:36 AM, Sarah Mollenkopf smollenk@gmail.com wrote:

I would like to create a variable that defines certain weeks. Community
health workers in the program do an active sweep of their village to seek
out patients every week. I would like to create a variable that defines
what week of the program the data gathering occurred in. I would also like
to create a variable that defines the epidemiological week of data
collection. How do I do this? I tried to do some math with the dates but I
couldn’t make it work.This is what I wrote:

if(double(today)>=16621 and double(today)<=16627,“Ratissage
1”,if(double(today)>=16628 and double(today)<=16634,“Ratissage
2”,if(double(today)>=16635 and double(today)<=16641,“Ratissage
3”,if(double(today)>=16642 and double(today)<=16648,“Ratissage
4”,if(double(today)>=16649 and double(today)<=16655,“Ratissage 5”,“Pas
Commencer”)))))


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to a topic in the
Google Groups “commcare-users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/commcare-users/oNBtW97H5Jw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Preventative Health Educator
US Peace Corps Senegal
MPH Epidemiology Candidate
Tulane University School of Public Health and Tropical Medicine
Master’s International Program
E: smollenk@gmail.com
P: +221.77.673.0087

Dear Clayton,

thank you for this,
so, that I needed, but How I can use . can you give example

best regards
Ahmed

Hi Ahmed,

Are you also trying to detect the week of the year for a specific date input, or are you trying to detect how many weeks have passed since a given date?