DateTime Formula returns 12/30/1899

I am working on the Timesheet App and have been advised that to in order to achieve calculation of Overtime Hours, I need to set Time In and Time Out to DateTime formula.

Using the Now() initial value, this functions optimally in Time In but when a User Clocks Out and initiate Time Out the recorded date is โ€œ12/30/1899โ€

I believe this is because the Initial value cannot be set to Now()

How best can I mitigate this issue?

0 20 4,858
20 REPLIES 20

If your column type in sheet is DateTime and same with the column type in the app, the NOW() is the correct expression into your initial value field.

If NOW() is set on TimeOut then App captures the same data in Time In and Time Out, basically the user is not given option to Clock Out.

@Sinethemba_Gayiza
Provided you are using action buttons for Clock In and Clock Out, then you shouldnโ€™t be using any initial values already.

oops

@Lynn
@Sinethemba_Gayiza needs Datetime, not just time because he needs to calculate some overtime hours. What happens if the user clocks out the next day? You can never know that with only time value.

Sorry just showing actions, will delete. Dont want to confuse anybody.

@Sinethemba_Gayiza
I believe this is the 3rd or the 4th time you are asking the same question, so let me try to explain once more:
For Datetime type columns, the initial value is always NOW() and just for this moment itโ€™s calculated as 5/9/2019 12:37:23 am

For Time type columns, the initial value is always TIMENOW() and just for this moment itโ€™s calculated as 12/30/1899 12:37:23am. For Time type columns, a date of 12/30/1899 is automatically appended (which is called Joda Date) because in Unix systems there is no time value, there is only datetime value and itโ€™s concatenation of date & time basically. And this is by-default and by-design like this.

For Date type columns, the initial value is always TODAY() and just for this moment itโ€™s calculated as 5/9/2019 12:00:00 am. For Date type columns, a time of 12:00:00am is automatically appended (which is called Joda Time) because in Unix systems there is no date value, there is only datetime value and itโ€™s concatenation of date & time basically. And this is by-default and by-design like this.

For Duration type columns, there is no initial value expression like above, because itโ€™s a calculation column of 2 date, time or datetime values.

In general; for Time In and Time Out or Clock In and Clock Out, it will be essential if the column types are set as Datetime BOTH in the gSheet and the appโ€™s column structure, as the calculation will be more specific and clear. Because, you cannot now to which specific date that entered time value belongs to.

Letโ€™s have a sheet like this and letโ€™s do some basic Math:


Option#1


Basics: Concatenate [Date] & [Time] columns and find the duration between this concatenation and [DateTime] column.

DATETIME(CONCATENATE([Date]," ",[Time])) - [DateTime]

OR

DATETIME([Date]&" "&[Time]) - [DateTime]

Here is how AppSheet interprets this expression and makes the calculation. The result is 24:00:00 or 1.00:00:00. Notice how the [Date] and [Time] column values are evaluated.


Option#2


Basics: Find the difference between [Datetime] and [Date] columns as duration

[Date] - DATE([DateTime])

Here is how AppSheet interprets this expression and makes the calculation. The result is 24:00:00 or 1.00:00:00. Notice how the [Date] and [Time] column values are evaluated.


Option#3


Basics: Find the difference between [Time] and [Datetime] columns as duration

[Time] - TIME([DateTime])

Here is how AppSheet interprets this expression and makes the calculation. The result is 00:00:00 or 0.00:00:00. Notice how the [Date] and [Time] column values are evaluated.

Hope itโ€™s clear now

I am trying to get my way around this @LeventK, on the gSheet both Time In and Time Out are set to DateTime formula but I still get the 12/30/1899 date

@Sinethemba_Gayiza
Can you please share your timesheet app with levent@able3ventures.com email as a co-author and the gSheet with edit access pls? This way it will be a lot more easier.

Thanks @LeventK , as I had mentioned previously, I had deleted the first App and copied again. On this copy I am yet to create Overtime Columns because I wanted to first solve the DateTime issue

@Sinethemba_Gayiza
I have fixed it. The reason of 12/30/1899 date is because you are trying to record a TIMENOW() value to a DATETIME type column with the Clock Out action.

Thank you so much @LeventK, going forward I will just copy this same App

Youโ€™re welcome. Please remove the sharings.

I get these errors when I input App Formulas for Overtime columns:

  1. IFS(
    HOUR([Total Hours]) >= 8,โ€œ08:00:00โ€,
    TRUE,[Total Hours]
    )

Error message: IFS function is used incorrectly:Inputs to IFS() must be condition-value pairs. Input 4 is not a value of a consistent type.

  1. (HOUR([Overtime Hours]) + MINUTE([Overtime Hours]) / 60 + SECOND([Overtime Hours]) / 3600) * [Overtime Pay]

Error message: Parameter 1 of function HOUR is of the wrong type

Also, how do I have the above Overtime Wage calculation to Calculate normal wage at Normal rate X 1.5?

@Sinethemba_Gayiza
Check the column types for [Total Hours] and [Overtime Hours]

Expression in #2 produces a Number not a Duration

They are all on Duration. My main concern is the first question.

IFS(
HOUR([Total Hours]) >= 8,โ€œ08:00:00โ€,
TRUE,[Total Hours]
)

IFS function is used incorrectly:Inputs to IFS() must be condition-value pairs. Input 4 is not a value of a consistent type.

"08:00:00" is a Time, "008:00:00" is a Duration (believe it or not).

So @Steve you advise I add another 0 before 8?

Sure, give it a try.

Thank you so much @Steve, it worked

Top Labels in this Space