Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the day of a date

Tags:

date

vb.net

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.

like image 549
Matt Avatar asked Nov 04 '09 10:11

Matt


People also ask

How do you extract the day of the week from a date?

Go to the Number tab in the Format Cells dialog box. Select Custom as the Category. Add dddd into the Type field for the full weekday name or ddd for the abbreviated weekday name. Press the OK button.

Can Excel tell me what day of the week a date is?

The WEEKDAY Function[1] is an Excel DATE and TIME Function. The function will return an integer that is a representation of the day of the week for a given date.


2 Answers

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
like image 120
Fermin Avatar answered Sep 20 '22 22:09

Fermin


You want to look at the format strings for the ToString method. MyDate.ToString("dddd") will get you what you want.

like image 32
PhilPursglove Avatar answered Sep 17 '22 22:09

PhilPursglove