Avatar of rivkamak
rivkamak
Flag 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 %>
.NET ProgrammingVisual Basic.NETASP.NETWeb Languages and Standards

Avatar of undefined
Last Comment
Craig Wagner

8/22/2022 - Mon
TheAvenger

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 %>
jss1199

If Weekday(Date) = vbSaturday Or Weekday(Date) = vbSunday Then
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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SAMIR BHOGAYTA

hi...
please use this

System.DateTime.Now.DayOfWeek
rivkamak

ASKER
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
Craig Wagner

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.