Search code examples
sqlibm-midrange

SQL on IBM i - Selecting data based on combined fields from DB


We are trying to select records from a file containing sales data where the date in the IBM i file is stored in 3 separate numeric fields (Year, Month, Day). We have a .net application that is using date pickers to select a from and through date range. Is there a way in an SQL statement to combine the 3 fields from the database into a single value so that the database date can be used to make the SQL select easier?


Solution

  • Use the digits command to tie them together. Your parameters will be YYYYMMDD.

    Where digits(year) || digits(month) || digits(day)  BETWEEN ? and ?