vb.net Date

FCapo
FCapo used Ask the Experts™
on
Hi,

I have a binding source and I'd like to filter a set or records only in the current week based on today's date. for example, today is the 1st of July, I'd like to see all the records between Monday the 29th of June and Friday the 3rd of july.

thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
it depends upon your underlying tables somewhat.


    source1.Filter = "DateField BETWEEN '" & Date1.tostring("yyyy/mmm/dd") & "' AND '"  & Date2.ToString("yyyy/mmm/dd") & "'"



https://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.filter(v=vs.110).aspx
Lead Software Engineer
Commented:
To find Monday of the current week using the current date, you can use the DayOfWeek property:
YourDate.AddDays(1 - Convert.ToInt32(YourDate.DayOfWeek))
To find Friday of the current week using the current date, you can use the DayOfWeek property:
YourDate.AddDays(5 - Convert.ToInt32(YourDate.DayOfWeek))

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial