![]() |
| ||
| ToString to Display day of the week OK I had C/C++ programming classes a few years ago and now I'm taking a ASP.net class and programming in C#. I need a little help with an assingment. We have to create an if state to display text depending on if the day of the week is a weekday vs weekend. I was able to get the time to dispaly ok. This next step I was taking before I created my if conditions was to try and display the day of the Week. Which I am unable to do. Any help would be appreciated. Also I don't have a compiler to test my code. I was trying to view the errors in IE. I added a web.config file to the root of my directory but it still does not give my an error description. Not sure if I have it in the correct place. Here is the code for my program: [ <script Language="c#" runat="server"> |
| ||
| Re: ToString to Display day of the week Shouldn't MyTime = DayOfWeek.Now; be something like MyTime = (DateTime.Now);. Then you should be able to do MyTime.DayOfWeek since DayOfWeek is a property of the DateTime class, so should be called on an instance variable of that class. I havent fiddled too much with the DateTime mechanism yet in C#, but this seems like it should work. Regards, Tyler S. Breton |
| ||
| Re: ToString to Display day of the week Thanks A Bunch It Worked. |
| ||
| Re: ToString to Display day of the week you can do as follows: mydate=system.date.now.date; date sdate; sdate=mydate.dayofweek(); /////it will return actual day e.g. sunday, monday,etc if (dayofweek==weekday) /////do some thing try it best of luck |
| ||
| Re: ToString to Display day of the week Try this: public static bool IsWeekday(DateTime dtInput) If it's a weekday, it returns true, otherwise false. |
| ||
| Re: ToString to Display day of the week Quote:
|
| All times are GMT -4. The time now is 12:22 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC