Calculate Hours from datetime

Is there a way to get a start time (datetime) and and end time (datetime)
and then do a calculation to get the number of hours between the two?
Thanks. I've tried it many different ways, but it seems to only access the
date part of datetime and not the hours. Anybody have any ideas for me?
Thanks in advance.

Just include the metadata fields in your form
type name start start end end today today

Then you need to pull the data (from servers or phone or odk folder)
using ODK Briefcase, use excel to "text to columns" ,

Next is to set up the format in those colums to Number-Hour format
(14-03-01 13:30).
it looks like this :
B2 C2
D2
SubmissionDate start
end 10/06/2013 17:31 10/06/2013 13:08 10/06/2013 13:11
Then you just need to maka a simple calculation in a new column

=D2-C2

Hope it helps

Jorge Durand Zurdo
*joduzu@gmail.com

Dear All,

Is there any update on this issue?

··· On Thursday, June 13, 2013 at 2:21:49 AM UTC+3, Bryan Taylor wrote: > Is there a way to get a start time (datetime) and and end time (datetime) and then do a calculation to get the number of hours between the two? Thanks. I've tried it many different ways, but it seems to only access the date part of datetime and not the hours. Anybody have any ideas for me? Thanks in advance.

I was hoping to have the user specify both datetime fields as a work period
and then calculate the hours in the collection form and display then in a
note field. I could write a python script for post processing to do just
about anything, but I really wanted to do it within the form. Thanks for
the help.

··· On Jun 12, 2013 5:11 PM, "Jorge Durand Zurdo" wrote:

Just include the metadata fields in your form
type name start start end end today today

Then you need to pull the data (from servers or phone or odk folder)
using ODK Briefcase, use excel to "text to columns" ,

Next is to set up the format in those colums to Number-Hour format
(14-03-01 13:30).
it looks like this :
B2 C2
D2
SubmissionDate start
end 10/06/2013 17:31 10/06/2013 13:08 10/06/2013
13:11
Then you just need to maka a simple calculation in a new column

=D2-C2

Hope it helps

Jorge Durand Zurdo
*joduzu@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/um9g921Qu1c/unsubscribe?hl=en
.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Bryan,

I don't think you can get an accurate date diff, but you can approximate it
with something like this...

<xf:bind nodeset="/data/ApproximateAge" readonly="true()" type="int"
calculate="if(/data/AgeType='BirthDate', ((now()-/data/BirthDate) div
30.4375), (if(/data/AgeInMonths > 0, ((/data/AgeInYears *
12)+/data/AgeInMonths), (/data/AgeInYears * 12))))"/>

If that doesn't work, you might be able to convert the dateTime to a string
(using format-date), substring to get the hours (using substr), and then
subtract those. http://opendatakit.org/help/form-design/binding should help.

Yaw

··· -- Need ODK help? Go to http://nafundi.com for custom features, form design, implementation support, and user training for ODK.

On Wed, Jun 12, 2013 at 6:47 PM, Bryan Taylor yngiss.bt@gmail.com wrote:

I was hoping to have the user specify both datetime fields as a work
period and then calculate the hours in the collection form and display then
in a note field. I could write a python script for post processing to do
just about anything, but I really wanted to do it within the form. Thanks
for the help.
On Jun 12, 2013 5:11 PM, "Jorge Durand Zurdo" joduzu@gmail.com wrote:

Just include the metadata fields in your form
type name start start end end today today

Then you need to pull the data (from servers or phone or odk folder)
using ODK Briefcase, use excel to "text to columns" ,

Next is to set up the format in those colums to Number-Hour format
(14-03-01 13:30).
it looks like this :
B2 C2
D2
SubmissionDate start
end 10/06/2013 17:31 10/06/2013 13:08 10/06/2013
13:11
Then you just need to maka a simple calculation in a new column

=D2-C2

Hope it helps

Jorge Durand Zurdo
*joduzu@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/um9g921Qu1c/unsubscribe?hl=en
.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

Try it with a simple form. What happens?

Yaw

··· On Tue, Feb 21, 2017 at 11:14 AM, wrote: > Dear All, > > Is there any update on this issue? > > > On Thursday, June 13, 2013 at 2:21:49 AM UTC+3, Bryan Taylor wrote: >> Is there a way to get a start time (datetime) and and end time (datetime) and then do a calculation to get the number of hours between the two? Thanks. I've tried it many different ways, but it seems to only access the date part of datetime and not the hours. Anybody have any ideas for me? Thanks in advance. > > -- > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en > > --- > You received this message because you are subscribed to the Google Groups "ODK Community" group. > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.

This is most likely currently broken.

I'm not sure whether date calculations will work or not.

Currently, the date(.) and format-date(.) functions all truncate the date
to the yyyy/mm/dd value -- the time is lost.

I have added a date-time() and format-date-time() method to javarosa for
the next ODK Collect release. Have not tested it on calculations.

Mitch

··· On Thu, Jun 13, 2013 at 8:53 AM, Yaw Anokwa wrote:

Bryan,

I don't think you can get an accurate date diff, but you can approximate
it with something like this...

<xf:bind nodeset="/data/ApproximateAge" readonly="true()" type="int"
calculate="if(/data/AgeType='BirthDate', ((now()-/data/BirthDate) div
30.4375), (if(/data/AgeInMonths > 0, ((/data/AgeInYears *
12)+/data/AgeInMonths), (/data/AgeInYears * 12))))"/>

If that doesn't work, you might be able to convert the dateTime to a
string (using format-date), substring to get the hours (using substr),
and then subtract those. http://opendatakit.org/help/form-design/bindingshould help.

Yaw

Need ODK help? Go to http://nafundi.com for custom features, form design,
implementation support, and user training for ODK.

On Wed, Jun 12, 2013 at 6:47 PM, Bryan Taylor yngiss.bt@gmail.com wrote:

I was hoping to have the user specify both datetime fields as a work
period and then calculate the hours in the collection form and display then
in a note field. I could write a python script for post processing to do
just about anything, but I really wanted to do it within the form. Thanks
for the help.
On Jun 12, 2013 5:11 PM, "Jorge Durand Zurdo" joduzu@gmail.com wrote:

Just include the metadata fields in your form
type name start start end end today today

Then you need to pull the data (from servers or phone or odk folder)
using ODK Briefcase, use excel to "text to columns" ,

Next is to set up the format in those colums to Number-Hour format
(14-03-01 13:30).
it looks like this :
B2 C2
D2
SubmissionDate start
end 10/06/2013 17:31 10/06/2013 13:08 10/06/2013
13:11
Then you just need to maka a simple calculation in a new column

=D2-C2

Hope it helps

Jorge Durand Zurdo
*joduzu@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/um9g921Qu1c/unsubscribe?hl=en
.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Dear Members,

Is there any update on this? Can we calculate difference in start and end times now with current version of 1.4.4??

Thank you

Dear Members,

Is there any update on this? Can we calculate difference in start and end
times now with current version of 1.4.4??

Thank you

··· El viernes, 17 de octubre de 2014 08:16:03 UTC-3, planne...@gmail.com escribió: > > Dear Members, > > Is there any update on this? Can we calculate difference in start and end > times now with current version of 1.4.4?? > > Thank you > >

Still broken. This is a big broken area of the underlying code.

The work-around is to ask for hours and minutes separately, then do your
time calculations using these integer values.

Ugly, awkward, frustrating.

No resources to fix this.

Dear All,

Is there any update on this issue?

Unfortunately, no. Code contributions are always welcome.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Wed, Sep 16, 2015 at 1:38 PM, cmwange@gmail.com wrote:

Dear All,

Is there any update on this issue?

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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