Format Date

One of the things I find myself looking up frequently is Date Values for SharePoint. When creating custom display forms, you typically end up with date and time values that look something like this: 2013-07-24T21:00:00Z. This isn’t really a useful value (to an end user). To change it to something more readable open designer and the disp form:

Find the date field:

My Start Time field looks like this in the form:
date_field
The corresponding code in designer:
date_field_code
The xsl:value of tag contains the information to modify. The select attribute is equal to the EventDate value, which is the Start Time. To make a more readable value, it can be changed to:
date_field_code_changed
The ddwrt namespace must be included to use a function like FormatDate. FormatDate, like the name implies, will change the formatting shown above to something useful or readable to an end user. Explanation of the parameters taken from the msdn page:
“The parameter szDate is converted to a DateTime. Based on the formatFlag parameter, which can have a value 0–15, a new DateTime string is constructed in the given locale lcid. Table 5 shows the results returned from this function.”
The above code will result in the below; a nicely formatted date for end users:
date_field_changed
Check the msdn article for a list of formats.
Advertisements

Workflows won’t publish

So this can be incredibly frustrating. You update a workflow, save it without errors and then publish, but the next time the workflow runs your changes aren’t there and it’s running an older version. I have a post about dealing with an issue like this, but after following my own advice and clearing out the previous versions, I still had the same problem . I stumbled upon this blog post that explains the problem. There is a SPD activity cache for your local machine and clearing that out will solve the problem.

The path for me on 64 bit Windows 7 looks like this: %System Drive%\Users\%user name%\AppData\Local\Microsoft\WebsiteCache. Inside that directory there was a folder for each SharePoint site I have worked on and occasionally an identically folder with “01” or “02” after the name. All of these directories can be deleted. Make sure you have closed SPD designer before deleting the directories, then reopen designer and publish a workflow.