Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

checking for day of week in asp.net

Posted on 2013-12-12
8
Medium Priority
?
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1120 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to count occurrences of each item in an array.

618 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