Reputation: 81
I have a series of dates formatted as:
26/03/1992
12/06/2010
13/01/1995
etc... it's in DD/MM/YYYY. I need to find the day like "Tuesday", "Monday" etc out of them.
I know I need to parse the date or something but I'm unsure how to go about this.
Upvotes: 8
Views: 82116
Reputation: 21
The best thing it works for me in vb 2010 is
I add timer and enabled it then i put it like that
Label6.Text = Format(Now, "dddd/dd")
"dd"
gives me the day Num.
"dddd"
gives me the name of the day
Upvotes: 2
Reputation: 11
'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class ArgumentOutOfRangeException
Inherits ArgumentException
Implements ISerializable
'Usage
Dim instance As ArgumentOutOfRangeException
Upvotes: 1
Reputation: 15813
Convert the date into a date datatype, then use the format function. This displays monday:
Dim d As Date
d = "11/23/2009"
MsgBox(Format(d, "dddd"))
You could also get a numeric day of the week using d.DayOfWeek.
Upvotes: 1
Reputation: 12589
You want to look at the format strings for the ToString method. MyDate.ToString("dddd")
will get you what you want.
Upvotes: 5
Reputation: 172468
Have a look at the documentation of the DateTime members Parse, TryParse, DayOfWeek and ToString.
Upvotes: 0
Reputation: 36111
You can cast it as a DateTime and use the DayOfWeek property which returns a DayOfWeek enumerator.
Not sure in VB.NET but in C# it's like
DateTime.Now.DayOfWeek or DateTime.Parse(theDateString).DayOfWeek
Upvotes: 8