📜 ⬆️ ⬇️

We do the countdown timer in Google tables

If you have nothing to do while waiting for a new project, and you only have Google tables at hand, you can make a countdown timer, for example, to find out how much free time you have left.

To make the timer just use a couple of functions:

NOW - displays the current date and time in a “date” format.
RAZNAT (DATEDIF) - calculates the number of remaining days, months and years between two dates. By default, the current day is taken into account.
DAYS (DAYS) - calculates the number of days between two dates.
HOUR - returns the hour component at a specified time, and can also calculate the difference in hours between two dates.
MINUTE (MINUTE) - works in the same way as the HOUR function, only for minutes.

Suppose we want to know how many days are left before the birthday of Habr - May 26, according to Wikipedia.
')

Initial settings


In order for the timer to be constantly updated and display the actual information, it is necessary to change the calculation settings in the table.

In the open table, select the menu item "File" go to "Table Settings" and on the "Calculations" tab, select "Calculation Updates" - "With changes and every minute."

image

Timer formulas


In the example, I made a timer of two kinds:

to display the remaining days, hours and minutes,
and
to output months, days, hours and minutes.

The only difference is that in order to calculate the number of the remaining whole months and days, it is necessary to use the RAZDAT function, whereas for outputting only the number of days, the DAYS function is sufficient.

There is also a SECOND function (SECOND) which allows you to output seconds, but due to the fact that the computation time range is limited to “once a minute” - the seconds timer simply will not have time to be updated.

We write formulas for timing


The example uses cells:

A2 - the final date from which we are counting
B2 is the current date, you can also use the NOW function instead.

Months
=DATEDIF(B2;A2;"M")
Number of days excluding entire months:
=DATEDIF(B2;A2;"MD")
Number of days in general
=DAYS(A2;B2)
Clock
=HOUR(A2B2)
Minutes
=MINUTE(A2B2)

In the simplest form of execution, we display the timer values ​​in separate cells:



Using the CONCATENATE function, you can output all data in one cell.

For this example, the formula is

=CONCATENATE(DATEDIF(B2;A2;"M");"month";":";DATEDIF(B2;A2;"MD");"day";":";Hour(A2B2);"hour";":";Minute(A2B2);"min")



or to count only days

=CONCATENATE(DAYS(A2;B2);"day";":";Hour(A2B2);"hour";":";Minute(A2B2);"min")





Additionally, you can set in the table additions that will send notifications under certain conditions, for example, upon reaching a certain number of remaining days. But they only work if the table is open in a window.

An example file is located by reference .

Source: https://habr.com/ru/post/451666/


All Articles