2 Replies - 33432 Views - Last Post: 01 November 2007 - 05:29 AM Rate Topic: -----

#1 dmxxmd  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 30
  • Joined: 26-October 07

How do I get the day of the week?

Post icon  Posted 01 November 2007 - 03:30 AM

hi guys, im building a clock in c# and everything is going okay the thing is I want the current Dayofweek to display in a label..but there is no such option like Dayofweek.now();

To get the date and time is no prob

DateTime date = DateTime.Now;
label1.Text = System.Convert.ToString(date);

But to get only the current day of the week is my problem..

thank you guys lookin foward to hear what you have to say..

DMXXMD

Is This A Good Question/Topic? 0
  • +

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How do I get the day of the week?

Posted 01 November 2007 - 05:14 AM

.Net fortunately offers a DayOfWeek Property of the DateTime Class. To get the name of the current day of the week, get a datetime variable, set that to Now, then use the DayOfWeek Property, like so

DateTime dt;
dt = DateTime.Now;
dt.DayOfWeek.ToString();



If you were to compile that code and MessageBox.Show(dt.DayOfWeek.ToString()) you'd get Thursday (or the day of the week where you're at if you not in North America :) )

Hope that helps :)
Was This Post Helpful? 1

#6 dmxxmd  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 30
  • Joined: 26-October 07

Re: How do I get the day of the week?

Posted 01 November 2007 - 05:29 AM

Thanx alot buddy It helps me 100%:)[size=3]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1