By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,425 Members | 1,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,425 IT Pros & Developers. It's quick & easy.

DateTime brain teaser

P: n/a
Hi all,
I'm struggling with an elegant way to figure out if a DateTime falls
between any Firday @ 6pm and Sunday @ 9pm.

For example:
If i want to fax a message b/w Fri 6pm and Sun 9pm on any given time
on any given day.

ne1?
~Gordon
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

An instance of DateTime has DayOfWeek and Hour properties you might use.
DateTime dt = DateTime.Now()
if (dt.DayOfWeek == DayOfWeek.Friday && dt.Hour >= 18 || dt.DayOfWeek ==
DayOfWeek.Saturday || dt.DayOfWeek ==DayOfWeek.Sunday && dt.Hour <= 21)
{
}
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Simple Simon" <re***@newsgroup.only> wrote in message
news:92********************************@4ax.com...
Hi all,
I'm struggling with an elegant way to figure out if a DateTime falls
between any Firday @ 6pm and Sunday @ 9pm.

For example:
If i want to fax a message b/w Fri 6pm and Sun 9pm on any given time
on any given day.

ne1?
~Gordon

Nov 15 '05 #2

P: n/a
Many thanks Miha :)

On Sat, 7 Feb 2004 11:07:54 +0100, "Miha Markic [MVP C#]" <miha at
rthand com> wrote:
Hi,

An instance of DateTime has DayOfWeek and Hour properties you might use.
DateTime dt = DateTime.Now()
if (dt.DayOfWeek == DayOfWeek.Friday && dt.Hour >= 18 || dt.DayOfWeek ==
DayOfWeek.Saturday || dt.DayOfWeek ==DayOfWeek.Sunday && dt.Hour <= 21)
{
}


Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.