none
Datepicker with date and time but only date is set to current?

    Question

  • Hi,

    I have a datetime field on a list with default date set to current and I customize the form in InfoPath designer. I have a requirement that the current date should be set but the current time should be blank and the user has to manually enter it, how can I achieve this without custom code?

    Thanks in advance.

    Wednesday, May 30, 2012 4:45 AM

Answers

  • Hi triple9

    What you could do in this case is to insert two controls: 1st date picker, 2nd text box.

    Then you can set date picker to today() as default value and set some forrmating rules to the text box to handle the time.

    Just before you save form you can use concat() function: concat(datefield, " ", timefield)

    Hope this will help


    Regards, Marcin (Please mark as helpful or answered if it helps)

    • Marked as answer by triple9 Monday, June 04, 2012 1:16 AM
    Wednesday, May 30, 2012 8:09 AM

All replies

  • Hi triple9

    What you could do in this case is to insert two controls: 1st date picker, 2nd text box.

    Then you can set date picker to today() as default value and set some forrmating rules to the text box to handle the time.

    Just before you save form you can use concat() function: concat(datefield, " ", timefield)

    Hope this will help


    Regards, Marcin (Please mark as helpful or answered if it helps)

    • Marked as answer by triple9 Monday, June 04, 2012 1:16 AM
    Wednesday, May 30, 2012 8:09 AM
  • Hi Marcin,

    Thanks it works but when I save it gets stored as "2012-05-31T00:00:00 11:00", why the T00:00:00?

    Wednesday, May 30, 2012 11:55 AM
  • Hi Triple9

    Please refer to following article:

    http://blog-rat.blogspot.com/2011/04/datetimeparse-problem.html

    Basically InfoPath date and time fields are strings with a special formating (therefore you see "2012-05-31T00:00:00"). You can then create form load function and format this string using substring() function.

    If you use InfoPath form library you may specify datetime field in sharepoint and that should store data in appropriate format.

    Please also make sure you specify today() function in date picker not now().

    Hope this will help.

    
    
    

    Regards, Marcin (Please mark as helpful or answered if it helps)

    Wednesday, May 30, 2012 12:55 PM