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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GreymanMSCConnect With a Mentor Commented:

        '-- 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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
zkeownCommented:
It's not going to until Sunday at 10:30AM... :)
0
 
John AccountAuthor Commented:
ahem hem...the date and time is changed to the present, for testing purposes. Does not work.
0
 
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
All Courses

From novice to tech pro — start learning today.