skij
asked on
ASP.NET/C#: Numerical Day of the Week
In ASP.NET/C#, I use this to get the current hour:
Server.Time.ToString("%H")
How can I get the numerical day of the week as a number between 1 and 7 where 1 is Sunday and 7 is Saturday?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
*No Points*
DateTime is in the System namespace, so be sure to bring that in somehow.
e.g.
Use the +1 if you want to start at one. The DayOfWeek enum starts its values at zero (i.e. Sunday = 0).
DateTime is in the System namespace, so be sure to bring that in somehow.
e.g.
System.Datetime.Now.DayofWeek + 1
Use the +1 if you want to start at one. The DayOfWeek enum starts its values at zero (i.e. Sunday = 0).
ASKER
How can I do this without using the system interface?
For example, sometimes I need to access past dates, not just NOW, like this:
Print(PingPrevious.Closing Time.ToStr ing("%H")) ;
I am looking for a way to use this with .ToString(()
For example, sometimes I need to access past dates, not just NOW, like this:
Print(PingPrevious.Closing
I am looking for a way to use this with .ToString(()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Error CS0103: The name 'Datetime' does not exist in the current context
I need something that will work with THIS same type of format:
Open in new window