이전달 중 토,일에 해당하는 일자를 모두 찾고싶다.
예시로 1월달이면 6,7,13,14,20,21,27,28 이렇게 숫자로 구하고 싶다
assgin로 찾는 방법을 알려줘 너무 어려워
Hello @wjdehdnr456
It is a working code:
BlankProcess62.zip (3.1 KB)
Solution which I used:
- Assign:
currentDate = DateTime.Now - Assign:
firstDayPrevMonth = New DateTime(currentDate.Year, currentDate.Month - 1, 1)
- If
currentDate.Month = 1(January), thenfirstDayPrevMonth = New DateTime(currentDate.Year - 1, 12, 1). - Otherwise,
firstDayPrevMonth = New DateTime(currentDate.Year, currentDate.Month - 1, 1).
- Assign:
lastDayPrevMonth = firstDayPrevMonth.AddMonths(1).AddDays(-1) - Assign:
nextDate = firstDayPrevMonth - While Loop:
nextDate <= lastDayPrevMonth
- If:
nextDate.DayOfWeek = DayOfWeek.Saturday Or nextDate.DayOfWeek = DayOfWeek.Sunday- Add to Collection: Add
nextDateto the list of weekend dates
- Add to Collection: Add
- Assign:
nextDate= nextDate.AddDays(1)(Incrementdateby one day)
Result:

2 Likes
Hi,
Can you try the following expression?
targetYear = 2024
targetMonth = 1
Then
arrDays = Enumerable.Range(1,DateTime.DaysInMonth(targetYear,targetMonth)).Where(Function(i) New DateTime(targetYear,targetMonth,i).DayOfWeek= DayOfWeek.Saturday OrElse New DateTime(targetYear,targetMonth,i).DayOfWeek= DayOfWeek.Sunday).ToArray()
If you need previous month, the following will help you.
targetYear =DateTime.Now.AddMonths(-1).Year
targetMonth = DateTime.Now.AddMonths(-1).Month
Sample
Sample20240108-1a.zip (2.7 KB)
Regards,
2 Likes
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
