Link to home
Start Free TrialLog in
Avatar of John Account
John Account

asked on

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

Avatar of zkeown
zkeown
Flag of United States of America image

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

Avatar of John Account
John Account

ASKER

Nope, that didn't do anything.
It's not going to until Sunday at 10:30AM... :)
ahem hem...the date and time is changed to the present, for testing purposes. Does not work.
ASKER CERTIFIED SOLUTION
Avatar of GreymanMSC
GreymanMSC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow, thanks so much, GreymanMSC. That's a really awesome way of doing it.
Awesomeness
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?
Oh...nevermind! I'm testing on my local machine; hence the time on my computer, lol. Duh. Sorry.