D
D
Dalgat4442022-03-16 10:19:41
Bitrix24
Dalgat444, 2022-03-16 10:19:41

How to check if a birthday is in a certain period?

There is a check-in date and a check-out date. Need to determine whether the client will have a birthday during their stay at our hotel? The problem is that the date of birth will not be 2022. That is, it is impossible to simply compare between the dates of settlement and eviction, for example, 03/16/1980 in both cases will be less.
The transaction card indicates the date of settlement and the date of eviction.
The date of birth is indicated in the contact card.
In the robot, at a certain stage of the transaction, it is necessary to determine whether the birthday will be during the period of residence.
Is it possible to use substr with a 'date' type variable?
As an option, I tried to subtract the date of birth from system:now using datediff with the '%y' parameter to calculate the difference in years, and then add it to the date of birth and compare with the dates of arrival and departure. But, in any case, after datediff the variable does not get the difference in years, but always gives 01/01/1970.
How to change the year of birth in the year of settlement?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2022-03-16
@alexey-m-ukolov

03/16/1980 is a date of birth, not a birthday. Birthday in the sense in which you use this term in this case is 03/16/2022. You can already compare this date with the dates of settlement. Difficulties here are added by the option of arrival and departure in different years, but they are also easily resolved.
In other words, you take the year of arrival, substitute it into the date of birth and check that the resulting date falls within the range. Then repeat the same for the year of departure, if it differs from arrival. If at least somewhere fell into the range, then others will be in the hotel.

A
Andrey Nikolaev, 2022-03-20
@gromdron

As an option, I tried to subtract the date of birth from system:now using datediff with the '%y' parameter to calculate the difference in years, and then add it to the date of birth and compare with the dates of arrival and departure.

Create 2 variables:
- Birthday (date)
- Difference in years (number)
First of all, calculate the difference (datediff with parameter y) between the current date and the date of birth and write the result in "Difference in years". It is in the numeric field, and not in the date - otherwise the result will be 1970.
Second, set "Birthday" as the result of dateadd between "Date of Birth" and the difference in years.
Third - compare :)
Is it possible to use substr with a 'date' type variable?

It is impossible, however, a field of type "Date" can be cast to a string and then it is possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question