Saturday, December 15, 2012

Localizing date

For July 16, 2012, and giving it a format of d in SSRS

  • Formatted in German as: 16.07.2012
  • Formatted in English as: 7/16/2012


Had the d format in English formatted July as 07 (i.e. double digits), we won't need special handling for English

Here's how to handle the special case, special cases are always evaluated first(pardon my captain-obviousness) on the conditions

=IIF(Parameters!NeutralLanguageCode.Value = "en", "MM/dd/yyyy", "d")


Here's the customized output for English: 07/16/2012



Likewise with date time (g format), we have to handle the special case, July 16 2012 6:00 PM


  • Formatted in German as: 16.07.2012 18:00
  • Formatted in English as: 7/16/2012 6:00 PM


=IIF(Parameters!NeutralLanguageCode.Value = "en", "MM/dd/yyyy hh:mm tt", "g")

Here's the customized output for English: 07/12/2012 06:00 PM

General formatting: http://msdn.microsoft.com/en-us/library/ms157406(v=sql.90).aspx

Granular formatting: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.71).aspx

No comments:

Post a Comment