I do a math to determine the time remaining for a scheduled time.

For example:

Now is 12/04/22 9:00. The scheduled time is 12/04/22 16:00. The math result is 7:00.

How do I make a template to be able to write “7h00min” ?

If it was more than 24hs, for example, 33:20 to write “1d9h20min” ?

You could look into the plugin column called “Format date”, you might be able to achieve this exactly.

I use the JavaScript column to do this. I’m abbreviating days as “d”, hours as “h”, mins as “m”.

```
if(p1) {
var delta = p1*24*60*60;
// calculate (and subtract) whole days
var days = Math.floor(delta / 86400);
delta -= days * 86400;
// calculate (and subtract) whole hours
var hours = Math.floor(delta / 3600) % 24;
delta -= hours * 3600;
// calculate (and subtract) whole minutes
var minutes = Math.floor(delta / 60) % 60;
delta -= minutes * 60;
// > 1 day
if(days >= 1) {
return days + "d " + hours + "h " + minutes + "m";
}
if(hours >= 1) {
return hours + "h " + minutes + "m";
}
else return minutes + "m";
}
```

Adapted from:

IIf you need to adjust it please tell me.

I pasted the code and in p1 I put the math but it returned me 24m when the result would be 24:10, that is, 1d00h10m.

Where did I go wrong?

How do I fill in the format?

I do the math like this: (d-now)/60

I don’t know if my mistake would be there

I would try removing the division by 60. The math column will already return a duration formatted in hours, minutes and seconds. Dividing my 60 throws off that result.

The default duration format is new, but the underlying format when calculating the difference between two dates is always in days. Anything to the left of the decimal is days and anything to the right of the decimal is the decimal fraction of a day.

Yeah, my math column was not having the division by 60.

Hi @ThinhDinh

how to add `formatted`

column to screen?

I use the text component, but it doesn’t appear on the screen

It worked. The error was in my formula.

Thank you friends for your usual attention.

Can you show me how you’re setting up in screenshots or a video?

The ultimate goal is a message sent to the client/patient via whatsapp on the eve of the appointment.

Obviously the Template print doesn’t have any formatting yet.

The goal is to always send a reminder the day before. It needed formatting including days in the situation of Friday remembering Monday events.

It is only as a result of the help you have given me that I reiterate my gratitude.

Ah thanks, actually I was asking @agung_Taufik about his problem but your explanation is clear about your usage!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.