Skip to main content
Solved

Problem with room occupancy

  • September 9, 2024
  • 1 reply
  • 17 views

Forum|alt.badge.img+10

In the form I have a data record field where all free rooms are displayed. All occupied rooms are not displayed. However, if I have a reservation for the future, the assigned room is immediately marked as occupied even though it is still available until the specific reservation date. So far I have no idea how to solve the problem.

Best answer by Pascal_Gallais-

Hello,

You could use a formula to check if the room is free "today":

Where the formula "free today" is:

 

IF(AND(DATETIME_DIFF(From,TODAY(),'days')<0,DATETIME_DIFF(TODAY(),To,'days')>0),"Yes",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')>0,DATETIME_DIFF(TODAY(),To,'days')<0),"Yes",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')<0,DATETIME_DIFF(TODAY(),To,'days')<=0),"No",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')<=0,DATETIME_DIFF(TODAY(),To,'days')<0),"No"
))))
 
Using the formula "Today()" may not be a good option since it's being computed all the time and can hence have some consequences on performances.
This being said, I guess that you want to compare reservation dates with customer required dates, meaning that you will not need to use the "Today()" function.
 
Regards,
 
Pascal

1 reply

Pascal_Gallais-
Forum|alt.badge.img+21
  • Inspiring
  • 213 replies
  • Answer
  • September 9, 2024

Hello,

You could use a formula to check if the room is free "today":

Where the formula "free today" is:

 

IF(AND(DATETIME_DIFF(From,TODAY(),'days')<0,DATETIME_DIFF(TODAY(),To,'days')>0),"Yes",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')>0,DATETIME_DIFF(TODAY(),To,'days')<0),"Yes",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')<0,DATETIME_DIFF(TODAY(),To,'days')<=0),"No",
IF(AND(DATETIME_DIFF(From,TODAY(),'days')<=0,DATETIME_DIFF(TODAY(),To,'days')<0),"No"
))))
 
Using the formula "Today()" may not be a good option since it's being computed all the time and can hence have some consequences on performances.
This being said, I guess that you want to compare reservation dates with customer required dates, meaning that you will not need to use the "Today()" function.
 
Regards,
 
Pascal