T
T
tefoxis2019-09-16 16:34:26
MySQL
tefoxis, 2019-09-16 16:34:26

How to calculate working time between two dates excluding holidays (Saturday, Sunday)?

Good afternoon!
Is it possible to calculate working time between two dates excluding holidays (Saturday, Sunday)?
By weekend I mean Saturday and Sunday. Holidays don't matter.
Working day from 9:00 to 18:00
I would like to get the result either in minutes or hours.
If we take approximate data, let's say date1 = 2017-01-26 12:00:00, date = 2017-01-30 12:00:00.
27.28 is Saturday and Sunday.
So the output should be in hours, for example:

| date 1             | date2               | buisness_time |
|2017-01-26 12:00:00 | 2017-01-31 15:00:00 | 9              |

Can this be implemented? So far, I only count through TIMESTAMPDIFF ...
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2019-09-16
@Fragster

It seems that I didn’t screw up, but there are more or less steps, so you can check: sqlfiddle.com/#!9/a6c585/115089
Working day boundaries are too lazy to add, but it’s not difficult.
At the same time, with a calendar it will be much easier and more versatile.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question