Hi everybody, Can some body tell me how can i find that which date (day,month and year) is selected in calender(I already have dropped calender on form) by pressing a button. Which code Should i wrote to find the date?
Thanks
Zeb-ur-Rehman
Loading

VulpesRank #55 · 29.2K reputationPosted Apr 28, 2011, 2:04 AM EDT
If you also have a namespace called DateTime then, as Shrikant said, I'd change it to something else. Otherwise, whenever you use the DateTime type, you'll always have to qualify it as: System.DateTime.
Jean PaulRank #32 · 38.5K reputationPosted Apr 27, 2011, 9:57 AM EDT
From your query I am not sure whether you are using ASP.NET / WinForms.
If you are using ASP.NET, Calendar1.SelectedDate should give the selected date.
There is a collection of dates property named SelectedDates for giving multiple date selections.
If you are using Windows Forms and MonthCalendar control, you have to use the control.SeletionStart and control.SelectionEnd datetime properties
(I believe this control is to specify a range of date by selecting the start and end dates)
Regards,
Jean Paul
Zeb Rehman68 reputationPosted Apr 27, 2011, 11:17 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 27, 2011, 12:45 PM EDT
If you are, then you can show the currently selected date with code such as the following:
Zeb Rehman68 reputationPosted Apr 27, 2011, 9:13 PM EDT
Soft CornerRank #1,221 · 1.5K reputationPosted Apr 27, 2011, 9:39 PM EDT
you need to convert it into DateTime and then store it in DB table , for e.g :
DateTime dt = Convert.ToDateTime(dateTimePicker1.Value.ToString("d MMMM yyyy"));
Zeb Rehman68 reputationPosted Apr 27, 2011, 11:18 PM EDT
Here it show me that DateTime is namespace but used as type.
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 27, 2011, 11:27 PM EDT
Soft CornerRank #1,221 · 1.5K reputationPosted Apr 27, 2011, 11:37 PM EDT
I guess your application name is "DateTime", if that so , then you need to Change it , bcz it will create ambiguity between namespace & datatype.