Wednesday, March 14, 2012

Format Date

If we want to filter DVWP to: Created Date > Today, we need to format the Created and format the Today().  In addition we need to “tell” the DVWP that the string is number. So it will look like this in the XPath editor:
[(number(ddwrt:FormatDateTime(ddwrt:FormatDate(string(@Created),1033,1),1033,’ddMMyyyy’))= number(ddwrt:FormatDateTime(ddwrt:FormatDate(string(ddwrt:Today()),1033,1),1033, ’ddMMyyyy’)))]
@Created The selected column.
'ddMMyyyy' The selected format of date (29/07/1989 -> 29071989)

In this XPath code we have to format both of them so they will be able to communicate with each other.

By this format of ddwrt:FormatDate(@Created),1033,’ddMMyyyy’) you can format the date to be as you wish. For example:
ddMMyyyy – 29071989
dd/mm/yy – 29/07/89
dd MMM yyyy – 29 Jul 1989
dd, MMMM – MM, yyyy – 29, July – 07, 1989

No comments:

Post a Comment