Skip to Content
author's profile photo Former Member
Former Member

Need formula help - query on characters in a text field

Post Author: bemmerich

CA Forum: General Feedback

In the database, phone numbers are stored as text, not numbers. Example 123-456-7890

How do I query so that I choose only phone numbers in the format where the 4th character is a dash ➖ and the 8th character is a dash?

This will exclude foreign phone numbers, which is my goal.

Thank you!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 09:26 PM

    Post Author: jsanzone

    CA Forum: General Feedback

    Bemmerich,

    what reporting tool are your working in? If it is WebI, then when you build a query, in your Query Filters section where you bring the object over and want to use as a filter, choose from the drop-down selector next to "Equal to" and find the option "Matches pattern", then in the next field manually type ___-___-____ and voila you will be able to filter properly on US-type phone numbers. The "Matches pattern" method translates to the "like" capability in SQL. The underscore (_) is the single wild card character, so using three underscores followed by a dash, followed by three more underscores, dash, and followed by four more underscores tells SQL to consider the fourth and 8th character positions where both are a dash.

    If you're using other tools like Crystal or Designer, then you may be able to use actual SQL coding and thus can employ the substring capability, which IMHO is more efficient in terms of machine execution, etc, etc. For instance: where substring(phone_no,4,1)='-' and substring(phone_no,8,1)='-'

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.