Function to isolate start and end dates in date/time field

Date/time fields can include both start and end times for display on calendars. I need a function to isolate each of these entries (start date/time, end date/time) in order to calculate the duration of an event. This would be similar to the functions that isolate parts of the Name, Address and URL fields.

402034816812

I think you can get the time using Laura's method above and then do calculations on that.

For example, use the formula Right({Date/Time},7) to get full time, then use Right({Date/Time},2) to get am/pm and Left({Date/Time},5) to get the hours:mins on the new field. You can then calculate the hours in between. It's going to take quite a few fields, but should be something doable.  

 

definitivamente es necesario que knack tenga esa función de poder manejar la hora en un datetime, yo tengo un problema, en la programación que estoy haciendo tengo lo siguiente, un campo del tipo datetime llamado FechaRecoleccion y otro campo del tipo datetime llamado FechaEntrega y quiero usar estas condiciones:

1.- si el campo FechaRecoleccion es mayor al campo FechaEntrega entonces me debe mandar un mensaje que diga "la fecha de recolección debe ser anterior a la fecha de entrega" (el problema de esta sentencia es que cuando pongo en FechaRecoleccion: 28/08/2020 8:00am y FechaEntrega: 01/09/2020 8:00am me manda el mensaje: "la fecha de recolección debe ser anterior a la fecha de entrega", la fecha es correcta pero hay conflicto con las horas que al ser iguales lo toma como si fuera la fecha y no la hora).

2.- si el campo FechaRecoleccion es igual al campo FechaEntrega pero la hora de la fecha de recolección es mayor a la hora de fecha de entrega entonces me debe decir que la hora de fecha recolección debe ser menor a la feche de entrega. (el problema es que no se puede manipular la hora como para especificar la segunda parte de la sentencia).

Estoy tratando de usar javascript para esta parte, este es el código, si pueden aportar su opinión o alguna idea se los agradecería:

// Validacion de los campos FechaRecoleccion y FechaEntrega
$ (documento) .on ('knack-view-render.view_116', function (evento, vista, datos) {
$ ("# view_116 .kn-button"). on ("clic", función () {
// si la fecha de recoleccion es menor a la fecha de entrega y la hora de recoleccion es
// menor o igual a la hora de entrega regresa un true
if ($ ("# view_116-field_176 .kn-dateValue ()"). val () <("# view_116-field_177 .kn-dateValue ()") &&
$ ("# view_116-field_176 .kn-timeValue ()"). val () <= ("# view_116-field_177 .kn-timeValue ()")) {
confirm ("1.-Fecha incorrecta");
devuelve verdadero;
} // si la fecha es igual y la hora de recoleccion es mayor o igual a la hora de entrega
// regresa un falso
else if ($ ("# view_116-field_176 .kn-dateValue ()"). val () == ("# view_116-field_177 .kn-dateValue ()") &&
$ ("# view_116-field_176 .kn-timeValue ()"). val () == ("# view_116-field_177 .kn-timeValue ()")) {
alert ("2.-La hora de la fecha de recolección no puede ser mayor a la hora de la fecha de entrega");
falso retorno;
}
// si la fecha de recoleccion es mayor a la fecha de entrega regresa un false
else if ($ ("# view_116-field_176"). val ()> ("# view_116-field_177")) {
alert ("3.-La fecha de entrega debe ser posterior a la fecha de recolección");
falso retorno;
}
más{
alerta ("4.-La hora de entrega debe ser posterior a la hora de recolección");
falso retorno;
}
})
});

Wow, I am soooo frustrated to see I can't do this. I never imagined you would have a field with a start time and an end time, and no ability to calculate the duration between these times. 

 

We need to calculate how long our staff are spending on our jobs so we can track profitability. They are currently entering time sheet data using an advanced date field. I am so disappointed we can't use that data to build a report :(

In addition to the above, also need the capability to extract the repeat information in the date field or the ability to use the dates and repeat-ability in the "Tasks" somehow.

An example of the problem is that if you want to create a scheduled item that repeats daily, but also have the capability to mark that day complete. Right now I have the calendar dates and repeat features separated into separate fields so that I can use a "Task" to generate new records daily that can be marked complete. The problem with this approach is that it doesn't work with the calendar functions. So as a workaround I have my staff entering the data twice, once in the manual fields (start date, end date, repeat, repeat how often) and once in the Knack repeating date field. That introduces data entry problems. Which also brings up the point that you can't validate the start, end, or repeat-ability of the date field with separate fields.

Hi Nova - 

We can for see how this feature would be useful and have it recorded as one on our often requested list.

In the meantime, we can offer a workaround using a text formula function of right() to extract a certain number of characters from a specific side of a field:
![](upload://smdEPKNjXDeXV6ERt8ntpBjayne.png)
So this works with a date/time field and takes the 7 characters from the right side, which looks like this in resulting records:
![](upload://sUFyToxjQikfS1CWfBAQPlKNS2S.png)If you were using a Date/Time field with From-To or a Timer field, you could employ the left() function as well.

Depending on your app's requirements, this may be not be a perfect fit due to the limitation is that that resulting text formula value cannot then be mapped onto another date/time field via conditional rule. Currently those field types are too different and currently not compatible in that way.

There's another similar and quite active thread here in the forum as well.

Thanks!

Bump.  This functionality would be useful.