Link to home
Start Free TrialLog in
Avatar of adspmo
adspmo

asked on

How to check the Calendar for an existing Vacation time

Hi Guys

I need to test somethiing

When a person books a holiday by setting a Startdate and an Endate it should check to see if the time has already been Approved or scheduled as vacation, Sick or any other Leave type. This has to be done against the name in the NameFull field.

So I Jack has already booked off Dec 1-3rd and Jill has Already booked of Dec 1 - 3rd and Jack then Books off Dec.1-3rd again it will prompt and say that Jack has already booked that time off.

James

ASKER CERTIFIED SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HemanthaKumar
HemanthaKumar

Forgot to do this...Convert CurrentDates and Booked to text in @Ismember function.
In the simple example you gave (Jack books the same exact set of days twice), it WILL be posible, because there will be an exact match.  But if theer is no exact match, you would not be ablet to key off the dates, because some part of teh dates would not match.

For example, if Jack already booked Dec 1-3, then tried to book Dec 2-4, there is no exact match, even though there is an "overlap match" if you consider all the in-between dates. (Dec 2 is the middle of the first booking and teh start of the second, whiel Dec 3 is the ned of teh first booking and themiddle of the second.)

You can get around this by getting a list of ALL dates a person has booked, so that you get back Dec 1, Dec 2, and Dec 3 for that first booking. You can then compare all the returned dates against all the dates in teh new booking.  That's basically what Hemantha has proposed, but is is somewhat inefficient to do this.

Another way would be to use script.  Have a view sort on the start dates.  Skip entried where the end is after the new attempted start, stop looking when the entry start is after the new attempted end, and anything you find in between indicates an overlap.
Avatar of adspmo

ASKER

temp := @DbLookup( "" : "NoCache" ;""; "FullName" ; NameFull;"StartDate");
sDate := @If(@IsError(temp); @Return(0); temp);
temp1 := @DbLookup( "" : "NoCache" ;""; "FullName" ; NameFull;"EndDate");
eDate := @If(@IsError(temp1); @Return(0); temp1);
Booked := @Explode( @TextToTime(@Text(sDate)) + "-" + @TextToTime(@Text(eDate)) );
CurrentDates := @Explode( @TextToTime(@Text(StartDate)) + "-" + @TextToTime(@Text(EndDate)) );
@If( @Text(@IsMember( CurrentDates; Booked)) ; @Prompt([OK]; "Conflict"; "Already you have booked vacation on these dates"); "")

Here is what I have and it fails

Incorrect dataType blabla....NumberExpexted

I will be running this in my Submit button so it will fail and stop if there is a conflict

James
@Text(@IsMember( CurrentDates; Booked)) I meant to be like this

@ISMember(@Text(CurrentDates); @Text(Booked))
Avatar of adspmo

ASKER

bla