eherencia
(Eherencia)
December 5, 2019, 11:36pm
#1
Hi,
I have 3 questions type text,
q1 hour from …time to,
q2 hour from … time to,
q3 hour from … time to.
I need to calculate the number of hours and minutes of the questions, for example:
q1: 08:30 am…09:45am,
q2: 10:45 am…12:45pm,
q3: 15:30 pm…18:30pm.
The result would be 6 hours 15 minutes. What would be the expression I should use?
sergiy
(sergiy)
December 6, 2019, 4:04am
#2
see around these threads
Use cases: Frequently, survey collect date and time in different formats than what Survey Solutions allows directly. Examples:
Facility opening/closing time. Consists of HH:MM AM/PM
Harvest time. Consists of MM/YYYY.
Year enterprise founded. Consist of YYYY
Bonus: duration or several dates (see another user’s request here )
Implementation ideas:
Where a broader question type exists, create more options (e.g., MM/YYYY should be an option for the date question)
Where necessary, create new ques…
Hi all,
I have generated two sets of long integers corresponding to dates:
Year1, Month1, Day1
Year2, Month2, Day2
I would like to use these to generate a new variable containing the days and one containing the months elapsed between these two dates.
I was looking into C# documentation, but I can’t seem to make the DateTime calculations required.
Can anyone help me out?
Best,
Giacomo
and possibly others at the forum.
eherencia
(Eherencia)
December 6, 2019, 6:58pm
#3
Hi sergiy, I have the following variables:
start hours --> (int.Parse (q1.Left (2)))
start minutes --> (int.Parse (q1.Right (2)))
activity_start --> (new DateTime (2019,1 , start_hours.InRange (0,1)? 2: 1,
(int) start_hours, (int) start_minutes, 0))
finish_hours --> (int.Parse (q1.Left (2)))
finish_minutes --> (int.Parse (q1.Right (2)))
duration --> ((activity_finish-activity_start ) .Value.TotalHours),
duration_str --> ((IsAnswered (duration))
? String.Format ("{0: F2}", duration)
: “#”),
activity_finish --> (new DateTime (2019,1, finish_hours.InRange (0,1)? 2: 1,
(int) finish_hours, (int) finish_minutes, 0)),
and this code to show the calculation of hours and minutes: HORARIO 1: %q1% - %q1% (%duration_str% hrs), however when I enter for example: 03:30 y 04: 55 it should show: 1.25 but it shows: 1.42. Where is the problem?
sergiy
(sergiy)
December 8, 2019, 5:12pm
#4
I don’t understand.
It should show 1.42 and it shows 1.42.
Why do you think there is a problem in the first place?
eherencia
(Eherencia)
December 8, 2019, 11:19pm
#5
Hi sergiy
I attach the image, it should show 1.25 (one hour and twenty minutes) not 1.42 (one hour and fourty two minutes.)
eherencia
(Eherencia)
December 8, 2019, 11:25pm
#6
Correction, it should show “an hour twenty five minutes” not “an hour fourty two minutes”.
sergiy
(sergiy)
December 9, 2019, 3:52pm
#7
It is not “one hour and forty two minutes ” it is “one point forty two hours ”.
Why you expect minutes there is a mystery to me. You are using TotalHours property, please read the function description before using it. Another reason to read the documentation is that it has an exact example for the task you are trying to achieve: