|
-
May 11th, 2007, 03:37 AM
#1
Thread Starter
Hyperactive Member
[2005] Clarity on date Objects
How can I display a string like :
Wednesday is the 5th day week of week number in 2007
?
Is that even possible?
-
May 11th, 2007, 04:01 AM
#2
Thread Starter
Hyperactive Member
Re: [2005] Clarity on date Objects
OK, figured out how to show the week number.
Code:
Dim sWeekOfYear As Integer = D.DayOfYear
Dim sWeek As Integer = (sWeekOfYear / 7)
Label9.Text = "Week " & sWeek.ToString
How can I show today's name, IOW, Wednesday ?
-
May 11th, 2007, 04:06 AM
#3
Re: [2005] Clarity on date Objects
Date.Today.DayOfWeek.ToString()
Also, note that, by many people's standards, the first week of the year is not simply the first 7 days. The first week of the year might have less than 7 days and it might start after the first of January, going by normal standards. Check out the CalendarWeekRule enumeration for more info.
-
May 11th, 2007, 04:13 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] Clarity on date Objects
Thanx for the info!
I get week number 19, so it seems to be correct.
One last question here, how do I display 'May' instead of 5 ?
-
May 11th, 2007, 04:53 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Clarity on date Objects
Figured out how to display 'May' :
Code:
Microsoft.VisualBasic.DateAndTime.MonthName(number)
Isn't there an easier way?
-
May 11th, 2007, 04:55 AM
#6
Fanatic Member
Re: [2005] Clarity on date Objects
I gess:
Code:
Date.Today.Month.ToString()
but i wasn't able to test/try it.
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
-
May 11th, 2007, 05:11 AM
#7
Thread Starter
Hyperactive Member
Re: [2005] Clarity on date Objects
Thanx, but that still shows 5
-
May 11th, 2007, 09:42 AM
#8
Re: [2005] Clarity on date Objects
If you want to format a date you use it's ToString method. "d" is for day, "M" is for month and "y" is for year. Where day and month is concerned you can specify 1, 2, 3 or 4 characters. 1 character is single digit, 2 characters is double digit (leading zero), 3 characters is abbreviated name and 4 characters is full name, e.g.
vb Code:
MessageBox.Show(Date.Today.ToString("dddd, d MMMM yyyy"))
displays "Saturday, 12 May 2007".
All this is in the MSDN library and if you'd searched for date format you'd have found it yourself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|