Answers.Body: <p>Short answer:</p>
  
  <p>This is a limitation/bug in CiviCRM. The advanced search handles postcodes correctly (ex: I can search postcode ranges H4 to H5), but most reports do not. It would be a feature that needs to be implemented in CiviCRM reports.</p>
  
  <p>Longer answer, if you are a developer:</p>
  
  <p>We could fix it by changing the filter type in the report, but then US-style postal code would lose the ability to search by range. I'm not too sure how to implement that in the report.</p>
  
  <p>Ex: civicrm/CRM/Report/Form.php in function addAddressFields():</p>
  
  <pre><code>    'postal_code' =&gt; array(
        'title' =&gt; ts('Postal Code'),
        'type' =&gt; 1,
        'name' =&gt; 'postal_code',
      ),
  </code></pre>
  
  <p>Should be:</p>
  
  <pre><code>    'postal_code' =&gt; array(
        'title' =&gt; ts('Postal Code'),
        'type' =&gt; CRM_Utils_Type::T_STRING,
        'name' =&gt; 'postal_code',
      ),
  </code></pre>
  
  <p>but, as I mentioned, this breaks "search postcode between X and Y". The advanced search has a checkbox to enable "search by range", and it works for UK/Canada-style postcodes, but I'm not sure how to implement this for reports.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-26T20:46:19.373Z
Answers.Text: Why can't we search between x and y if it's a string type? Seems like we should be able to - perhaps that's where the effort should go? In any case, US postal codes are not really numbers either (some start with '0', and then there's that suffix bit sometimes), so I think you have identified a bug that should be fixed ... [hehe, and I'm also from Canada ...]
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-27T15:18:17.457Z
Answers.Text: @AlanDixon : we should add an option similar to the one in advanced search. The filter "between X and Y" works in the report is because CiviCRM implements that only for "Integer" filters. I'm not sure what's the best solution: implement "between X and Y" for strings? (it would show up everywhere, might be confusing), or add a new filter "Postal Code range" with custom handling?
Answers.UserDisplayName: bgm
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-28T13:08:15.143Z
Answers.Text: Thanks for the advice on this.  I'll give the code you suggest a run and assess with my users which option they feel would be most beneficial.  Better handling of the Postcode string would be useful, although I'm not sure what the best solution would be.   Has anyone tested the postcode functionality in 4.7 to see if there is any improvement?  I have other issues preventing me looking at 4.7 at the moment
Answers.UserDisplayName: user2914
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-02T15:16:33.287Z
Answers.Text: @bgm - good point, and yes a specific postal code range handling filter makes sense, especially because there may be some locales that need special treatment (e.g. removal of spaces, etc.).
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-22T15:11:57.473Z
Answers.LastActivityDate: 2016-04-22T15:11:57.473Z
Answers.UserDisplayName: bgm
Answers.Body: <p>Although you have the localisation file installed, do you have the setting in Administer/localization/address settings/Default Country actually set to United Kingdom?  I do have it set up like this and it works for me by allowing UK post codes to be entered alpha/numerically.  I am using civicrm 4.7.6 with Wordpress 4.5.1  Incidentally, I did not install the localisation file and haven't found a need for it, yet.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-03T07:16:31.727Z
Answers.Text: Yes, the default country is set to UK.  The issue isn't with entering the UK postcode in to a contact, this works fine, but the utilisation of reporting by postcode. When you attempt to set a report filter based on a UK postcode, the report only accepts integer postcodes, i.e. US.  Entering an alphanumeric postcode returns an error of incorrect data in the field.  
  
  For the moment I think I will be advising users to generate the report the require, without the postcode filter and then export to CSV.  Excel can then be used to filter by postcode and obtain the required information.
Answers.UserDisplayName: user2914
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-30T21:28:20.980Z
Answers.LastActivityDate: 2016-04-30T21:28:20.980Z
Answers.UserDisplayName: peterb
Body: <p>I am currently running tests with CiviCRM 4.6.14 and have custom functionality working as we require.  During testing by the end user, an issue has come to light with the 'Postcode' field. </p>
  
  <p>Despite having the UK localization installed, the report filters are still treating the postcode field as an integer.  UK postcodes are a mixture of letter and numbers and I need to be able to query the database using these.<br>
  Have I missed something in the localization?  Is there something I can alter so the postcode field is interrogated as an alphanumeric rather than integer?</p>
  
  <p>Any help would be appreciated.
  Many thanks
  Russell</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-23T20:35:36.437Z
Comments.Text: Could you please specify what platform you are using (Wordpress, Drupal etc) and how did you import your contacts?
Comments.UserDisplayName: peterb
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-28T13:03:40.043Z
Comments.Text: I have CiviCRM installed on Windows IIS installation with Wordpress as the CMS.  All contacts address details are added manually at moment while I am testing
Comments.UserDisplayName: user2914
Tags: <reports><postcode>
Title: How can I change the 'Postcode' field to work with UK postcodes?
ThreadText: # How can I change the 'Postcode' field to work with UK postcodes?
  
  (Asked by: username_0 on 2016-04-22)
  
  I am currently running tests with CiviCRM 4.6.14 and have custom functionality working as we require. During testing by the end user, an issue has come to light with the 'Postcode' field.
  
  Despite having the UK localization installed, the report filters are still treating the postcode field as an integer. UK postcodes are a mixture of letter and numbers and I need to be able to query the database using these.  
  Have I missed something in the localization? Is there something I can alter so the postcode field is interrogated as an alphanumeric rather than integer?
  
  Any help would be appreciated.
  Many thanks
  Russell
  
  **Tags:** reports, postcode
  
  > **Comments:**
  > **username_1**: Could you please specify what platform you are using (Wordpress, Drupal etc) and how did you import your contacts?  
  > **username_0**: I have CiviCRM installed on Windows IIS installation with Wordpress as the CMS.  All contacts address details are added manually at moment while I am testing  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-04-22. Score: 5
  
  Short answer:
  This is a limitation/bug in CiviCRM. The advanced search handles postcodes correctly (ex: I can search postcode ranges H4 to H5), but most reports do not. It would be a feature that needs to be implemented in CiviCRM reports.
  Longer answer, if you are a developer:
  We could fix it by changing the filter type in the report, but then US-style postal code would lose the ability to search by range. I'm not too sure how to implement that in the report.
  Ex: civicrm/CRM/Report/Form.php in function addAddressFields():
      'postal_code' => array(
        'title' => ts('Postal Code'),
        'type' => 1,
        'name' => 'postal_code',
      ),
  
  Should be:
      'postal_code' => array(
        'title' => ts('Postal Code'),
        'type' => CRM_Utils_Type::T_STRING,
        'name' => 'postal_code',
      ),
  
  but, as I mentioned, this breaks "search postcode between X and Y". The advanced search has a checkbox to enable "search by range", and it works for UK/Canada-style postcodes, but I'm not sure how to implement this for reports.
  
  > **Comments:**
  > **username_3**: Why can't we search between x and y if it's a string type? Seems like we should be able to - perhaps that's where the effort should go? In any case, US postal codes are not really numbers either (some start with '0', and then there's that suffix bit sometimes), so I think you have identified a bug that should be fixed ... [hehe, and I'm also from Canada ...]  
  > **username_2**: @AlanDixon : we should add an option similar to the one in advanced search. The filter "between X and Y" works in the report is because CiviCRM implements that only for "Integer" filters. I'm not sure what's the best solution: implement "between X and Y" for strings? (it would show up everywhere, might be confusing), or add a new filter "Postal Code range" with custom handling?  
  > **username_0**: Thanks for the advice on this.  I'll give the code you suggest a run and assess with my users which option they feel would be most beneficial.  Better handling of the Postcode string would be useful, although I'm not sure what the best solution would be.   Has anyone tested the postcode functionality in 4.7 to see if there is any improvement?  I have other issues preventing me looking at 4.7 at the moment  
  > **username_3**: @username_2 - good point, and yes a specific postal code range handling filter makes sense, especially because there may be some locales that need special treatment (e.g. removal of spaces, etc.).  
  
  ---
  
  ### Answer by username_1 on 2016-04-30. Score: 0
  
  Although you have the localisation file installed, do you have the setting in Administer/localization/address settings/Default Country actually set to United Kingdom? I do have it set up like this and it works for me by allowing UK post codes to be entered alpha/numerically. I am using civicrm 4.7.6 with Wordpress 4.5.1 Incidentally, I did not install the localisation file and haven't found a need for it, yet.
  
  > **Comments:**
  > **username_0**: Yes, the default country is set to UK.  The issue isn't with entering the UK postcode in to a contact, this works fine, but the utilisation of reporting by postcode. When you attempt to set a report filter based on a UK postcode, the report only accepts integer postcodes, i.e. US.  Entering an alphanumeric postcode returns an error of incorrect data in the field.    For the moment I think I will be advising users to generate the report the require, without the postcode filter and then export to CSV.  Excel can then be used to filter by postcode and obtain the required information.  
  
  ---
  
  