PDA

View Full Version : How to format date field in a formview


ABC123

dougeven
09-24-2015, 08:31 PM
Hi,

I have a datetime field in a list control that I want to display and edit in a formview. In the list control "Client-side" properties for the field I have "Date/time display format" set to "<Default - date portion only>." However in the formview this date field is shown with the time component (see attached screenshot). I can't find any properties in the Formview that would let me control the formatting for the date. Should the Formview respect the client-side property setting for "Date/time display format"? Any direction as to how can I attack this problem?

Thanks.

-Doug

41072

Sarah Mitchell
09-25-2015, 12:35 PM
Hi,

I have a datetime field in a list control that I want to display and edit in a formview. In the list control "Client-side" properties for the field I have "Date/time display format" set to "<Default - date portion only>." However in the formview this date field is shown with the time component (see attached screenshot). I can't find any properties in the Formview that would let me control the formatting for the date. Should the Formview respect the client-side property setting for "Date/time display format"? Any direction as to how can I attack this problem?

Thanks.

-Doug

41072

Great question, Doug!

You could use client-side templates for your field for displaying the date. All the data in the FormView are string (ie, character) types. Based on the image, you could apply the date format directive like so:



{MyFieldName:dateString('MM/dd/yyyy&&0h:0m:0s am','MM/dd/yyyy')}


There is a date format directive builder available in the List control. You can also access it from the Template Tester - an option for opening the Template Tester is available from the Web Projects Control Panel in the 'Tools' menu.

dougeven
09-25-2015, 06:39 PM
Thank you. I did not know about date format directives.