13,193,048 members (64,314 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 7: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<br />
DateTimePicker1.CustomFormat = "dddd"<br />```

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 355 Richard Deeming 235 Karthik Bangalore 200 Kornfeld Eliyahu Peter 160 Wendelius 145
 OriginalGriff 6,320 ppolymorphe 1,549 Karthik Bangalore 1,234 Jochen Arndt 880 Richard Deeming 824