Thursday, May 12, 2011

What about the issue of Calendar in SharePoint 2007 show wrong datetime.

I decided to post this issue because I did not find out any wrong in my system, and if it is a WAD or Bug, please confirm this topic is correct and I will send this link to my customer.


Install SharePoint 2007 with the default settings for everything. Create a celendar list and then create a column named "My Date Time" or something you want with DateTime type and show both Date and Time.

Create an item in Calendar with All Day Event checked, type a date into "My Date Time"

After save, everything is fine. Please see the picture in view form.

Title, AlldayEvent, My Test Datetime show correctly, data kept. But what is happening when I edit this item?

"My Test Datetime" was wrong, the date is minus 1 day and if I save this item, the data will store this date.

There is very strange that it will not change for the next editing. And this issue does not happen in SharePoint 2010

Tuesday, May 10, 2011

How to format datetime in SharePoint XSLT

In SharePoint (both of 2007 and 2010), Microsoft has implemented  XSLT 1.0 into CQWP (Content Query WebPart) and parse xsl file.

You can find out these file at 14\TEMPLATE\LAYOUTS\XSL, you will see some xsl files such as main.xsl, thread.xsl,... For now, you change reference version of xslt for these files, you will get an error because CQWP only understand the structure of XSLT 1.0. So, there are a lot of limitation to work on DateTime, String,...and other functionings of XSLT 2.0.

However, in SharePoint you can use an alias to get somes already formatted by using ddwrt namespance. Detail for more

It's very easy to use:

<xsl:value-of select="ddwrt:FormatDateTime('2010-may-25', 'G', 1033)"/>

First argument: Date original value
Second argument: Formatted expression, this argument has supported flag/string such as "d" (or 1) for date only as result as "M/d/yyyy"...
Third argument: regional setting. But no support for User Regional Setting