locked
Date and Time field RRS feed

  • Question

  • within my document library i have several field, also a date and time field.

    when i create a new document and i dont fill in the field iets standard the date of today.

    when i fill it up i can save it.

    that was easy, now comes the difficult part.

    when i want to edit my document properties, i want to place the date thats already entered back into the field.

    this is the step where its gooing wrong.

    string startdate= SPEncode.HtmlEncode(proditem["start contract"].ToString());
    DateTimeControl stDate= new DateTimeControl();
    stDate.SelectedDate = convert.toDate(date);

     

    the field is set like this : stDate.DateOnly = true;

    so i think i'm must get ownly the date out of it.

    what is gooing wrong?

    Tuesday, June 15, 2010 2:06 PM

Answers

  • Hi,

    I don't understand the relevant why do you need to get startdate and use it nowhere?

    string startdate= SPEncode.HtmlEncode(proditem["start contract"].ToString());
    DateTimeControl stDate= new DateTimeControl();
    stDate.SelectedDate = convert.toDate(date);

    If you need to retrieve date value of date time field, you can easily use cast the field object to DateTime.


    Best regards,

    Riwut Libinuko
    SharePoint Architect, Singapore
    Microsoft MVP | SharePoint Server | Singapore
    Blog : http://blog.libinuko.com
    • Marked as answer by kimvlas Wednesday, June 16, 2010 7:04 AM
    Tuesday, June 15, 2010 2:25 PM

All replies

  • Are you getting time also and even if you set DateOnly to true, you still get the time?

    instead of convert, try this exactparse function

    http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx


    Moonis Tahir MVP, MCPD, MCSD.net, MCTS BizTalk 2006/SQL 2005/SharePoint Server 2007 (Dev & Config)
    Tuesday, June 15, 2010 2:21 PM
  • Hi,

    I don't understand the relevant why do you need to get startdate and use it nowhere?

    string startdate= SPEncode.HtmlEncode(proditem["start contract"].ToString());
    DateTimeControl stDate= new DateTimeControl();
    stDate.SelectedDate = convert.toDate(date);

    If you need to retrieve date value of date time field, you can easily use cast the field object to DateTime.


    Best regards,

    Riwut Libinuko
    SharePoint Architect, Singapore
    Microsoft MVP | SharePoint Server | Singapore
    Blog : http://blog.libinuko.com
    • Marked as answer by kimvlas Wednesday, June 16, 2010 7:04 AM
    Tuesday, June 15, 2010 2:25 PM
  • when the user wants to edit the document fields, he must also have the possibility to adjust the contract start date.

    so when the value is in the datetimecontrol he can se it, and if possibile adjusting it.

    Wednesday, June 16, 2010 6:57 AM