12,072,534 members (62,200 online)
Rate this:
See more:
i wannna build a program where i type the date, and it returns me the day of that specific date.
how can i do that?
Posted 11-Feb-13 8:24am
Andreas Gieriet 11-Feb-13 18:06pm

You repeat yourself many times below. Read *carefiully*: DateTime is not DateTimePicker!
DateTime is a convenience class to hold dates and time (but not durartions - for that see the TimeSpan class).
Check out the DateTime class and see the constructors and the provided functions to give the day of the week, etc.
Cheers
Andi

Rate this:

## Solution 1

Look at the `DateTime.DayOfWeek` property.
appleduardo 11-Feb-13 14:55pm

but i cant use datetimepicker methods, how can i code it step by step by taking the given date as refference?

lets say i introduce a date through the datetime picker (feb 11 2013, for instance), and i want to know what day was on nov-23-2002 (which i have to type in 3 different textboxes) by taking the first date as a reference to calculate the second one.
Matt T Heffron 11-Feb-13 17:54pm

None of the solutions that referred to the DateTime data type mentioned using the DateTimePicker. They are different types. You CAN use DateTime without using DateTimePicker. Create the DateTime value: new DateTime(int year, int month, int day)
Rate this:

## Solution 2

Really :
`var day = DateTime.Parse("2013/2/11").DayOfWeek; // gives you monday`
appleduardo 11-Feb-13 14:55pm

but i cant use datetimepicker methods, how can i code it step by step by taking the given date as refference?

lets say i introduce a date through the datetime picker (feb 11 2013, for instance), and i want to know what day was on nov-23-2002 (which i have to type in 3 different textboxes) by taking the first date as a reference to calculate the second one.
Rate this:

## Solution 3

Hi,

Use the DateTime.Parse[^], the DateTime.ParseExact[^], the DateTime.TryParse[^] or the DateTime.TryParseExact[^] method to parse the given date.
Then, you can use the `DateTime.Day` or the `DateTime.DayOfWeek` property to get the day of that specific date.
v3
appleduardo 11-Feb-13 14:54pm

but i cant use datetimepicker methods, how can i code it step by step by taking the given date as refference?

lets say i introduce a date through the datetime picker (feb 11 2013, for instance), and i want to know what day was on nov-23-2002 (which i have to type in 3 different textboxes) by taking the first date as a reference to calculate the second one.
ProgramFOX 12-Feb-13 2:01am

You can use DateTime without using a DateTimePicker. With Parse, ParseExact, TryParse and TryParseExact, you can parse a string to a DateTime.
Rate this:

## Solution 6

Hi

You can use from bellow code for this action:

```int m = 11, y = 2002, d = 23;
DateTime time = new DateTime(y, m, d);

Console.WriteLine(time);
Console.WriteLine(time.DayOfWeek);
```

I hope it's helpful for you.
Rate this:

## Solution 4

Have a look here:
http://msdn.microsoft.com/en-us/library/system.datetime_methods.aspx[^]
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek%28v=vs.95%29.aspx[^]

[EDIT]

1) Use `ValueChanged` for event for DateTimePicker:
```Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
Dim dt As Date

dt = Me.DateTimePicker1.Value
Me.Label1.Text = dt.ToString & " is " & Format(dt, "dddd")

End Sub```

or

2) set `Format` and `CustomFormat` property for DateTimePicker control
```DateTimePicker1.Format = Custom DateTimePicker1.CustomFormat = "dddd" ```
DateTimePicker will show you only the name of day.

[/EDIT]
v2
appleduardo 11-Feb-13 14:55pm

but i cant use datetimepicker methods, how can i code it step by step by taking the given date as refference?

lets say i introduce a date through the datetime picker (feb 11 2013, for instance), and i want to know what day was on nov-23-2002 (which i have to type in 3 different textboxes) by taking the first date as a reference to calculate the second one.
Maciej Los 11-Feb-13 15:16pm

Do i ever wrote you to use DateTime picer methods? No.

Top Experts
Last 24hrsThis month
 OriginalGriff 410 Dave Kreskowiak 270 CPallini 255 F-ES Sitecore 220 Jochen Arndt 160
 Dave Kreskowiak 2,506 OriginalGriff 2,009 Richard MacCutchan 1,675 CPallini 1,377 CHill60 1,219