I am working on an old AS400 that does not support the SQL RIGHT () function, and I need SELECT strings based on the X rightmost characters of a number that can contain 7 or 8 characters using SQL.
How can I get what I want if I can’t use RIGHT and I don’t know the exact length of the number.
here is some context in the random case this is useful:
A number is a date, but is stored as a number, so the first zero is deleted by the database, as a result of which dates starting from zero, like 01032016 [read as 01-03-2016], will be truncated to 1032016).
the database is quite large, so querying all rows without filtering this field consumes quite a lot of resources and time.
Changing the format of the dates in the database to something more reasonable will result in breaking software changes that I don’t support, and this is critical.
source
share