I have a screen where the user selects a Time In and Time Out. They select the Hour, Minute, and AM/PM in three different dropdowns for Time In and Time Out:
I set three different fields to hold the date/time as below (DateIn, DateOutCk, DateOut). I then use the DateDiff between DateIn and DateOut to calculate the total 'Hours' (as below). The odd thing is when the screen loads (if it's a new record or pulling up an old one), the calculated field 'Hours' shows 32 hours, not 8 hours (which is the default when loaded - as in the picture above). But if the user changes the date, even slightly, it recalculates correctly. Not sure why this happens. Hopefully I explained this right. Maybe there's a better way. But I can't understand why this wouldn't work. If I highlight the code for DateOut it shows the right date and time, while it shows the wrong date, but right time in the field. I'm lost.
DateIn.text=
//Holds the Date In from the users selection (or loaded from the database).
DateTimeValue(Timesheet_Date.SelectedDate & " " & 'TimeInHour'.Selected.Value & ":" & 'TimeInMinutes'.Selected.Value & " " & 'TimeInAMPM'.Selected.Value)
DateOutCk=
//Holds the Time Out, but using the Timesheet Selected Date (which is the same as the DateIn).
DateTimeValue(Timesheet_Date.SelectedDate & " " & 'TimeOutHour'.Selected.Value & ":" & 'TimeOutMinutes'.Selected.Value & " " & 'TimeOutAMPM'.Selected.Value)
DateOut=
//Checks to see if the Time Out is earlier than Time In.
//If so, assume it then carried into the next day, so add a day to the Date, but keep the Time Out the user selected.
If(TimeValue('DateOutCk'.Text) < TimeValue('DateIn'.Text),
DateAdd(
DateTimeValue(Timesheet_Date.SelectedDate & " " & 'TimeOutHour'.Selected.Value & ":" & 'TimeOutMinutes'.Selected.Value & " " & 'TimeOutAMPM'.Selected.Value),
1,Days)
, //Else
DateTimeValue(Timesheet_Date.SelectedDate & " " & 'TimeOutHour_4'.Selected.Value & ":" & 'TimeOutMinutes'.Selected.Value & " " & 'TimeOutAMPM'.Selected.Value)
)

Report
All responses (
Answers (