Solved

checking for day of week in asp.net

Posted on 2013-12-12
8
347 Views
Last Modified: 2013-12-30
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 %>
0
Comment
Question by:rivkamak
8 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 39714979
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 %>
0
 
LVL 19

Expert Comment

by:jss1199
ID: 39714984
If Weekday(Date) = vbSaturday Or Weekday(Date) = vbSunday Then
0
 

Author Comment

by:rivkamak
ID: 39715789
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39716125
hi...
please use this

System.DateTime.Now.DayOfWeek
0
 

Author Comment

by:rivkamak
ID: 39717379
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.
0
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 280 total points
ID: 39726758
If you look up the documentation for DayOfWeek (http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek(v=vs.110).aspx) (instead of making others do your job for you) you'll see that it returns an enum, not a string.

DateTime.Now.DayOfWeek = DayOfWeek.Saturday
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Service to Receive TCP Packets 4 37
JavaScript error 1 33
Visual Studio editor? 1 12
Saveas need to save a copy 16 9
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now