Skip to Content
Author's profile photo Former Member

Passing Dates between reports: English vs French

After implementing a report that uses hyperlinks to pass dates in both English and French, it became apparent that the 2 languages require different
date formats in order to work. When passing a date to a target report’s prompt, the prompt expects the date in a certain format according to the document’s
locale. Failing to pass in dates in the required format will result in nothing being passed to the target report’s prompt.

Canadian date formats:

English (Canada):    “dd/MM/yyyy”

English (US):          “MM/dd/yyyy”

French (Canada):    “yyyy-MM-dd”

 

Since not all users will have the same Locale set in their browsers, the format to use needs to be set based on the browser’s selection.

To check the browser Locale setting and set the format dynamically in the report, you can use the Webi built-in function “Get Locale()”

eg: Create a variable that sets the proper date format based on browser locale. The following handles the Locales “English (CA)”, “English (US)”,
“English”, “French (CA)”, and “French”.

[DateFormat] =If GetLocale() = “fr_CA” Then “yyyy-MM-dd” ElseIf GetLocale() = “en_CA” Or GetLocale() = “fr_FR” Then “dd/MM/yyyy” Else “MM/dd/yyyy”

You can then use the formatting variable to format your date:

=FormatDate(

ToDate(

    Trim(

      Left(

        LeftTrim(UserResponse(“START”))

      ;Pos(UserResponse(“START”);” “)-1

      )

    )

;[DateFormat])

;”Mmm dd, yyyy”)

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.