Matt
Matt

Reputation: 81

Getting the day of a date

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

Answers (10)

Jerwin P.
Jerwin P.

Reputation: 1

In VB try this:

DateTimePicker1.Value.DayOfWeek.ToString

It works

Upvotes: 0

Gubi
Gubi

Reputation: 415

DateTime.Parse("2010/12/31").dayofweek

Upvotes: 2

almog.ori
almog.ori

Reputation: 7889

Try

dateValue.DayOfWeek.ToString()

Upvotes: 0

Ahmed Hassan
Ahmed Hassan

Reputation: 1

MsgBox(Now.Date.DayOfWeek.ToString)

Upvotes: -2

Beshara
Beshara

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

Ram
Ram

Reputation: 11

'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class ArgumentOutOfRangeException
    Inherits ArgumentException
    Implements ISerializable
'Usage
Dim instance As ArgumentOutOfRangeException

Upvotes: 1

xpda
xpda

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

PhilPursglove
PhilPursglove

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

Heinzi
Heinzi

Reputation: 172468

Have a look at the documentation of the DateTime members Parse, TryParse, DayOfWeek and ToString.

Upvotes: 0

Fermin
Fermin

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

Related Questions