Convert Date to Number

Hello,

I have date and I want make Calculate (hidden value) to convert the date to number like:
11-3-2018 to 43170
Because I need make unique number like: (iraq43170) Iraq is site.
My plan is:
concat(#form/site_h, #form/date_dob)
But it give me (iraq11-3-2018) i need the result to be (iraq43170).

best,
Ahmed

Hi Ahmed,

Would it be possible to wrap your date value in an int() function?

So, one option would be something like:

concat(#form/site_h, int(#form/date_dob))

Or alternatively, you could save the date in a hidden value using int(#form/date_dob) then reference it later in the second hidden value you are creating.

Thanks,
Kai

Dear Kai,

thank you for reply.
I tested it, and it give me the different number : 17067, and I need to give me 43176.
When I export the data it give me like: Iraq43176.
Please see the image in attache:


and see the example for Excel with Commcare:

So, in the Excel give me the number : 43176 when I convert the text to the date it give me 17/3/2018.
I hope that be clear for you.

More thanks for your Help.

Best regards,
Ahmed

Hi Ahmed,

"Day 1" for CommCare's serialized representation of a date starts on Jan 1, 1970.

Excel's "Day 1" is serialized to Jan 1, 1900.

You can adjust the dates coming out of CommCare by adding the relative number of dates (which you can find by converting the date one time. ie: int(date("1970-1-1")))

-Clayton

Dear Clayton,

thank you for your help,
it works.
1
best,
Ahmed