1

I am trying to apply the UK format to a date in a data view web part using the following method:

<xsl:value-of select="ddwrt:FormatDate(string(@EventDate) ,2057 ,3)" />

However, this seems to still be trying to revert to US dates (1033) which means the long dates are wrong.

Anyone know why this may happen and have a fix?

Regional settings are set to UK and other dates across the site seem to be displaying correctly. If I go to the calendar and edit the date, I know it works as it sits in October quite nicely where as a date of 6th October ends up as the 10th June in my DVWP.

Thanks

Matt

  • just wondered if there was any fix for this as I have come accross the same problem. My Region Settings are UK across the board. My DVWP uses the UK formatting for the date field, however the 2/4/2012 is showing as 4th Feb 2012. Any help would be appreciated. – user7699 Apr 4 '12 at 7:27
  • I have encountered the same problem with LCID 1037 and I wonder if you ever found a solution for it? Thanks! – user11264 Oct 11 '12 at 7:54
1

I just tried this in my US-en (1033) environment, and it seems to work fine. (I copied your XSL so that even the commas were in the exact same place.)

<xsl:value-of select="@EventDate" />::<xsl:value-of select="ddwrt:FormatDate(string(@EventDate) ,2057 ,3)" />

This is what is returned:

2010-10-01T05:00:00Z::01 October 2010 
2010-10-02T05:00:00Z::02 October 2010
2010-10-03T05:00:00Z::03 October 2010
2010-10-04T05:00:00Z::04 October 2010
2010-10-05T05:00:00Z::05 October 2010
2010-10-06T05:00:00Z::06 October 2010
2010-10-07T05:00:00Z::07 October 2010
2010-10-08T05:00:00Z::08 October 2010
2010-10-09T05:00:00Z::09 October 2010
2010-10-10T05:00:00Z::10 October 2010
2010-10-11T05:00:00Z::11 October 2010
2010-10-12T05:00:00Z::12 October 2010
2010-10-13T05:00:00Z::13 October 2010 

As you can see, the underlying data in the @EventDate column is Zulu time. Now, I'm assuming that you're working with a Calendar, and therefore, the built-in Site Column @EventDate. If it's your own column, then there could be other formats in it.

Try the XSL above and see what you see.

1

The output from your select="@EventDate" isn't the full ISO format (yyyy-mm-ddThh:mm:ssZ) - wonder if that has something to do with it...

  • Agreed, this seems likely - I've used the FormatDate function like that in the DVWP before without issue. – Andy Burns Dec 3 '10 at 17:44
0

Strangely, any date in the first 12 days will try and use a US date format but after that it works fine.

i.e. 06/10 = 10th June 13/10 = 13th October

Wierd

Matt

0

There could be a problem with the FormatDate function. I assume those numbers after it localize it to your region. Is that the correct LCID?

From your hint, it really does sound like the function has made the assumption of a US date for input MM/dd/yyyy. What if you pass in the date as ISO-8601, so its independent of any locale? yyyy-mm-ddTHH:mm:ss Z

0
06/10/2010 00:00:: 10 June 2010 
13/10/2010 12:00:: 13 October 2010  
20/10/2010 12:00:: 20 October 201

Ok so i did the short code for it and I got

06/10/2010 00:00:: 06/10/2010   
13/10/2010 12:00:: 10/13/2010   
20/10/2010 12:00:: 10/20/2010

This is so strange and makes no sense what so ever.

Someone help.

Thanks

Matt

(Marc - Can you try changing your region to UK and see if you still get the right output?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy