Asp.net 2.0 DateTime.Now event

I need help figuring out how to effectively use the DateTime.Now event in this circumstance: For my local churce, I will be streaming a live webcast starting at 10:30 every sunday morning. When a button for the Live Webcast is clicked, if the time is between 10:30 and 12:30, I want the click event to do something; if the time the button is clicked is not between 10:30 and 12:30 then do somethign else. Here's what I got so far, and I just don't think I got the right idea here. So, any help you can offer would be greatly appreciated. I'm doing this in VB, but I'll take any help you can offer--either in VB or C#. Thanks.
Protected Sub imgbtnWebcast_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbtnWebcast.Click
        If DateTime.Now.DayOfWeek = DayOfWeek.Wednesday Then
            If DateTime.Now.Hour > 11 Then
                'Do stuff here
            End If
        Else
            'Do other stuff
        End If
    End Sub

Open in new window

John AccountAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zkeownCommented:
Hmmm... try this.
If DateTime.Now.DayOfWeek = DayOfWeek.Sunday Then
 
    If Now.DayOfWeek = DayOfWeek.Sunday Then
        If Now.Hour >= 10 And Now.Minute >= 30 And Now.Hour <= 12 Then
              'Do your thing
        End If
    End If
 
End If

Open in new window

0
John AccountAuthor Commented:
Nope, that didn't do anything.
0
zkeownCommented:
It's not going to until Sunday at 10:30AM... :)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

John AccountAuthor Commented:
ahem hem...the date and time is changed to the present, for testing purposes. Does not work.
0
GreymanMSCCommented:

        '-- call the function just once instead of multiple times --
        Dim N As Date = DateTime.Now
        '-- determine that the current day is Sunday --
        If N.DayOfWeek.Equals(DayOfWeek.Sunday) Then
            '-- compare times of day --
            If N.TimeOfDay >= #10:30:00 AM#.TimeOfDay _
            And N.TimeOfDay <= #12:30:00 PM#.TimeOfDay _
            Then
                '-- do stuff for the correct time of day --
            Else
                '-- do stuff for the wrong time of day --
            End If
        Else
            '-- do stuff for the wrong day --
        End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John AccountAuthor Commented:
Wow, thanks so much, GreymanMSC. That's a really awesome way of doing it.
0
John AccountAuthor Commented:
Awesomeness
0
John AccountAuthor Commented:
Oh...darn. One thing I forgot to mention, GreymanMSC: I need the time to be the time on the Server. Anyway to easily make this represent the time on the server?
0
John AccountAuthor Commented:
Oh...nevermind! I'm testing on my local machine; hence the time on my computer, lol. Duh. Sorry.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.