Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

checking for day of week in asp.net

How would I write this if statement in asp.net?
i need a check to see if the day of the week is not Friday or saturday in VB.net
     
<% if WeekdayName(weekday(date)) <> "Friday" and WeekdayName(weekday(date)) <> "Saturday" then %>
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

It's better to use DayOfWeek. See here for details: http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek(v=vs.110).aspx

It would be something like:

<% if date.DayOfWeek <> DayOfWeek.Friday and date.DateOfWeek <> DayOfWeek.Saturday then %>
Avatar of jss1199
jss1199

If Weekday(Date) = vbSaturday Or Weekday(Date) = vbSunday Then
Avatar of rivkamak

ASKER

I got the following errors on both of yours
@: jss1199: C32093: 'Of' required when specifying type arguments for a generic type or method.
@TheAvenger:BC30469: Reference to a non-shared member requires an object reference.
Avatar of SAMIR BHOGAYTA
hi...
please use this

System.DateTime.Now.DayOfWeek
so what is wrong with this?
'if  System.DateTime.Now.DayOfWeek  = "Saturday"   Or System.DateTime.Now.DayOfWeek <> "Friday" Then
error: System.FormatException: Input string was not in a correct format.
ASKER CERTIFIED SOLUTION
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

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