Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143415 | Mar 19,2019 05:56 PM UTC | Mar 20,2019 10:45 AM UTC | WinForms | 1 |
![]() |
Tags: GridGroupingControl |
private void button1_Click(object sender, EventArgs e)
{
var today = DateTime.Now;
string expression = "[DOB] >= '" + today.GetPreviousWeeksDate(DayOfWeek.Sunday).Date + "' AND [DOB] <= '" + today.GetPreviousWeeksDate(DayOfWeek.Saturday).Date.DatesAbsoluteEnd() + "'";
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(expression);
}
public static class DateTimeExtension
{
public static DateTime GetPreviousWeeksDate(this DateTime givenDate, DayOfWeek dow)
{
int currentDay = (int)givenDate.DayOfWeek, endDay = (int)dow;
return givenDate.AddDays(-7).AddDays(endDay - currentDay);
}
public static DateTime DatesAbsoluteEnd(this DateTime dateTime)
{
return dateTime.Date.AddDays(1).AddTicks(-1);
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.