Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / August 2006

Tip: Looking for answers? Try searching our database.

Calendar.IsWeekend()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 18 Aug 2006 22:50 GMT
Hi;

Is there a way to determine if a given day in a Calendar is a weekend?
And/or can this be determined from the user's culture? Because it is
Friday/Saturday in the middle east and Saturday/Sunday in Europe/Americas,
and probably something else somewhere else.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

"Peter Huang" [MSFT] - 21 Aug 2006 10:30 GMT
Hi Dave,

Current I am doing some research on this issue and I will update you ASAP.

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 22 Aug 2006 03:29 GMT
Hi Dave,

Based on my research, there is no such a method to do that.
You may try to use the approach below to get the first day and know the
weekend should be the previous two days.

But there is also no 1-to-1 correlation between the "first day of the week"
and the weekend being the last two days in the week, either....

So I think you may try to considered your concrete scenario and do the
calculation.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen - 22 Aug 2006 15:23 GMT
This is not good. Sunday is the first day of the week here in the U.S. (I
think Monday is in Europe) so I don't think that will work.

We may have to hord-code it ourselves by locale. To that point - is it
Saturday/Sunday in PRC?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi Dave,
>
[quoted text clipped - 18 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 24 Aug 2006 08:26 GMT
Hi Dave,

Yes you are right, in PRC , the Saturday/Sunday is the Weekend. and
Monday-Friday is the Weekdays.

If you have any other concern, please feel free to let me know.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 28 Aug 2006 14:37 GMT
Hello Dave,

Just a little add-ons, yes, there is no direct method in .net FCL to
determine whether a given day is weekend (according to a given Calendar).
However, you can still easily do the work by using the
System.Globalization.Calendar and its derived classes. For example:

============================
System.Globalization.Calendar calendar = new
System.Globalization.GregorianCalendar(System.Globalization.GregorianCalenda
rTypes.Localized);

       Response.Write("<br/>today(Localized): " +
calendar.GetDayOfWeek(DateTime.Now));

       calendar = new
System.Globalization.GregorianCalendar(System.Globalization.GregorianCalenda
rTypes.USEnglish);

       Response.Write("<br/>today(USEnglish): " +
calendar.GetDayOfWeek(DateTime.Now));

       calendar = new
System.Globalization.GregorianCalendar(System.Globalization.GregorianCalenda
rTypes.MiddleEastFrench);

       Response.Write("<br/>today(MIDDLEEAST): " +
calendar.GetDayOfWeek(DateTime.Now));

============================

After you get the "DayOfWeek" value, you can determine whether it is
weekend.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.