try this
DateTime dtNow=dateTime.now
int nowdayofweek = (int)dtNow.DayOfWeek;
DateTime weekStartDate, weekEndDate ;
weekStartDate = Microsoft.VisualBasic.DateAndTime.DateAdd("d", 0 - dtNow.Day, dtNow);
FridayDate = weekEndDate = Microsoft.VisualBasic.DateAndTime.DateAdd("d", 4 - dtNow.Day, dtNow);
Katit wrote:
Get specific date (Day of Week)
12-Jul-07
I need to get Date for Monday and Friday of current week
I can't seem to find any better way then to DateTime.Now and loo
forward/backward incrementing/decrementing by 1 day until I reac
DayOfWeek
Any better way to do that?
Previous Posts In This Thread:
Get specific date (Day of Week)
I need to get Date for Monday and Friday of current week
I can't seem to find any better way then to DateTime.Now and loo
forward/backward incrementing/decrementing by 1 day until I reac
DayOfWeek
Any better way to do that?
Re: Get specific date (Day of Week)
I would try using the DayOfWeek property to add or subtrac
respectively to get to the date you need. Something like
Today is Thursday to get to friday try DateTime.Now.AddDays(7
(int)DateTime.Now.DayOfWeek
I didn't test this, just a thought
Katit, If you know the value for the day of the week for the day you are
Katit
If you know the value for the day of the week for the day you are
working with, then you can subtract that value from the DayOfWeek
enumeration from the DateTime. This will give you the Sunday for that week.
Then, you can just add Monday (1) or Friday (5) to get the DateTime
instances for those days of the week
--
- Nicholas Paldino [.NET/C# MVP
- (e-mail address removed)
Re: Get specific date (Day of Week)
Yeah! Thats right.
Thanks!
There is one subtle bug here.
There is one subtle bug here. You should store the value of Now into a
variable, as you are making the call to Now twice. On the off chance that
this is being run at midnight, it is possible that the first call to Now and
the second call to Now will produce DateTime values with different dates
--
- Nicholas Paldino [.NET/C# MVP
- (e-mail address removed)
Submitted via EggHeadCafe - Software Developer Portal of Choice
Adding WCF Service References
http://www.eggheadcafe.com/tutorial...9-dfa51a9fab8e/adding-wcf-service-refere.aspx