TechTalk: Partial Numeric Date Selection with SQL

SQL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Recently, I needed to select records using the year portion of a six-digit numeric date field for the selection criteria. I discovered two ways to construct an SQL statement to accomplish this (see 10). The key to both methods is the DIGITS function. The DIGITS function returns a character representation of a numeric column. Since a numeric column can then be treated as a character column, the column can be used with the LIKE predicate and with the SUBSTR function.

Recently, I needed to select records using the year portion of a six-digit numeric date field for the selection criteria. I discovered two ways to construct an SQL statement to accomplish this (see Figure 10). The key to both methods is the DIGITS function. The DIGITS function returns a character representation of a numeric column. Since a numeric column can then be treated as a character column, the column can be used with the LIKE predicate and with the SUBSTR function.

-Mary Ann Warren

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$