# calculate the number of customer stay in the days of weekends

hello , I need some help in this case .
I have 2 columns for arrival date , depart date , i want to know if the customer come in the Sunday or Saturday , or in the days from Monday to Friday , i use (date &time difference node ( to calculate how many days he stay ), and extract date &time fields node ) how can i complete this process ?

Hi @orobbsh , itâ€™s not clear what do you need help with.

Based on your screenshot, it looks like you are able to get the day of the week already, and you are able to get the number of days/nights.

What process are you trying to complete that you need help with?

Itâ€™s also best to share some data so we understand what the input looks like.

3 Likes

hi , i have a data hotel that contain arrival date , depart date , i need to know the period that customer stay in the hotel , i need to know the days he stay ( if he stay in Saturday and sunday as a weekend days , or he stay in the days from Monday to Friday
i start solving this by Subtract depart date from arrival date . and know the first day he come in the hotel . but still donâ€™t know each of day the customer stay

Hi @orobbsh , ok, so if I understood properly, you want to know how many week days and how many weekend days the customer was in for, correct?

I put something together for you that looks like this:

Results:

Hereâ€™s the workflow: Calculate number of weekdays and weekends of customer stay.knwf (33.4 KB)

Note: The calculated days include both arrival and departure days. If you want nights, the easiest thing to do is to adjust departure as departure - 1day. Probably create a new column called adjusted_departure or something.

5 Likes

your answer is very helpful , but i try to use it in my data , all the nodes execute but when i reach column expression it doesnâ€™t work , i leave it for 25 minutes but it is suspended
note : i have 135000 row .

Hi @orobbsh , this is a bit memory intensive.

Try with this modification. I added the feature where the workflow will run the Garbage Collector at every 1000th iteration (you can modify this number if you want). The addition looks like this:

Hereâ€™s the updated workflow: Calculate number of weekdays and weekends of customer stay.knwf (33.4 KB)

2 Likes

hi bruno29a , can you send me the right file modification . because this file is look like the past file .

Here you go: Calculate number of weekdays and weekends of customer stay.knwf (42.8 KB)

2 Likes

Hello @orobbsh,

combination of a your task, â€śone row per iterationâ€ť loop, number of rows and Column Expressions make this a bit complicated. Here is a different, loopless, approach.
Calculate number of weekdays and weekends of customer stay_ipazin.knwf (55.6 KB)

Br,
Ivan

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.