how to get weekend dates of the month ie i need dates of month which are sat and Sunday
Hi,
Hope the following helps you.
Let’s say td = DateTime.Today
Then
listSaturdayAndSnuday = Enumerable.Range(1,DateTime.DaysInMonth(td.Year,td.Month)).Select(function(d) new DateTime(td.Year,td.Month,d)).Where(function(x) x.DayOfWeek=DayOfWeek.Sunday OrElse x.DayOfWeek=DayOfWeek.Saturday).ToList()
note: listSaturdayAndSunday is List<DateTime>
type variable.
Regards,
@manojv02500
similar approach as @Yoichi with some variation
Preparation: (combine it with Yoichi’s approach: DateTime.DaysInMonth(firstDay.Year,firstDay.Month)
Statement:
Enumerable.Range(0,MonthDaysCount).Select(Function (x) firstDay.AddDays(x)).Where(Function (d) {0,6}.Contains(d.DayOfWeek)).toList
Find Demo XAML here:
GetAllWeekendDay_ByMonth.xaml (5.8 KB)
@ppr xaml is showing like
@Yoichi can you share an xaml as i am getting error
xaml was reworked and optimized. but i dont see any validation issues. Let it run/debug and inspect the variable.
What is missing at your end?
@Yoichi how can convert the date in 09012020 format
Hi,
how can convert the date in 09012020 format
Can you try the following ToString method?
item.ToString("MMddyyyy")
Regards,
@Yoichi how can i save sunday in diffrent variables
Hi,
How about the following?
listSnuday = Enumerable.Range(1,DateTime.DaysInMonth(td.Year,td.Month)).Select(function(d) new DateTime(td.Year,td.Month,d)).Where(function(x) x.DayOfWeek=DayOfWeek.Sunday).ToList()
Regards,
@Yoichi how can i save dates in different variable as i will need those dates
@Yoichi How to find the last sunday of last month
Hi,
Can you try the following?
firstDayThisMonth = new Date(today.Year,today.Month,1)
lastSundayLastMonth = firstDayThisMonth.AddDays(7*CInt(firstDayThisMonth.DayOfWeek=DayOfWeek.Sunday)-1*CInt(firstDayThisMonth.DayOfWeek))
You can also get it ffrom the above sundaylist if you set target date as some day in last month.
Enumerable.Range(1,DateTime.DaysInMonth(td.Year,td.Month)).Select(function(d) new DateTime(td.Year,td.Month,d)).Where(function(x) x.DayOfWeek=DayOfWeek.Sunday).ToList().Last()
Regards,
hi need a help for when in a month there is a 5 Sunday i been saving all sunday dates as i need to add those dates in file path how can i make sure if there are 5 sunday
Hi,
how can i make sure if there are 5 sunday
Hope the following helps you.
Let’s say
lastDayThisMonth = new DateTime(today.Year, today.Month, 1).AddMonths(1).AddDays(-1)
then we can check it by the following expression.
lastDayThisMonth.Day - CInt(lastDayThisMonth.DayOfWeek) >28
Regards,
Hi,
Can you set lastDayThisMonth as not List<DateTime>
but DateTime
type?
Regards,
Hi,
Can you show us the expression of IF condition or share your workflow?
Regards,