currently i m creating Visual web part , with SharePoint DateTimeControl trying to get select date from DateTimeControl programmatically .. how to get DateTimeControl selected date value.


You can get (or set) the selected value from code-behind (e.g. when user clicks a button) with myDateTimeControl.SelectedDate.

See https://karinebosch.wordpress.com/sharepoint-controls/datetimecontrol-control/ for examples (SharePoint 2007, but still relevant in 2013).

  • ok i'm working on it , and one more request -u have any article related to my question.. Jul 30 '15 at 9:15

Example of sharepoint date time control if id= "DateTimeStartDate"

Then in the code behind .cs file you can access its value like below.

item["StartDate"] = Convert.ToDateTime(DateTimeStartDate.SelectedDate.ToString());

  • 1
    The property SelectedDate is already a date, so I don't see the point in converting it to a string, and then back to a date...
    – Evariste
    Jul 30 '15 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.