how i can set Weekend
Question
Application Type
Reactive

how i can set Weekend

in my system 

working 5 days of week and weekend 2 days 

 i need Know the system the weekend =  a friday and a saturday

i need set weekend (a friday and a saturday)  

how can do this

mvp_badge
MVP

Hello Andrew.

Can you be more specific on what you are trying to do?

You can see what day of the week a date is with the function DayOfWeek(). What you do with it, will depend on your goal.

i need 

example

 user select vacation request From 26/2/2020 to 3/3/2021 

and Within this request There is a Friday or Saturday in this case. I want not to count these two days

when i use diffdays function 

how i can do this   


@andrew mahfouz 

You can use something like this...

Create an action with StartDate and EndDate as inputs and then execute a query that returns a list of dates between the start and end date

Then apply a for each that will compare if the day is Friday or Saturday, using the function that Nuno Reis said DayOfWeek() .

Check the screenshots

Hope this helps.

Regards

Gonçalo Almeida


can upload Oml 

Regards.

Gonçalo Almeida

DatesList.oml

Champion

Hi andrew ,

You don't need to use sql. There is DayOfWeek build-in function.

Please also refer to  https://success.outsystems.com/Documentation/10/Reference/Logic/Built-in_Functions/Date_and_Time_Built-in_Functions for more detailed information.

Cheers,

@Tom Zhao 

For the use case, he needs the sql in order to return a list of dates between a start and an end date, and then use the dayOfWeek() function to check if it's weekend or not by date.

At least that is my opinion.

Regards

Gonçalo Almeida

Champion

Hi @Goncalo Almeida 

Sorry, I didn't read your answer carefully.  But it could achieve the same feature without SQL.

Kind regards,


Use DayOfWeek(DateTime).

If it returns a 5 (Friday) or a 6 (Saturday) it's weekend (for your scenario).

Andrew, one question,

what I could see you want to know the number of vacation days not the number of weekends (Friday/Saturday) on your case, right?

You could do as Tom Zhao says but instead of counting  the weekday 5 or 6, count the other ones.

Also if you need the days, you could build a string with the dates separated by a single character like , or ; or #, your choice.

The best way I thing is to create a function witch returns what you want the way you want.

Best regards  

mvp_badge
MVP

Because this topic is now active again, and you are answering a distinct question, here goes the full flow:

Use DiffDays to get how many days exist between the two dates. Do Trunc of the difference by 7 to get the number of full weeks.

Weeks = Trunc(DiffDays(Date2,Date1)/7)

Now you have saved a few calculations.

For the final 0 to 6 days, just test if they are working days or weekends and add them to whichever variable is suitable.

Advance to the next day and repeat.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.