Manipulating 2-digit year

Database
N/A

Manipulating 2-digit year

Anyone know how i can get the 2 digit year (also with the flexibility to say add 1, or 2 years to it?)

It's easy enough to find the year (4 digits) but I can't get around to computing the year and getting only the last 2 digits. I have tried the following but it doesn't work:

select
extract (year from (Add_months (current_date, 12))) (char (2))

select
substr( (extract (year from current_date) +1), 3, 2)
2 REPLIES
Teradata Employee

Re: Manipulating 2-digit year

The result of EXTRACT is INTEGER, with default FORMAT '-(10)9'.

If you want the result in CHAR format, just use two CASTs; the first just specifies the conversion format and the second actually converts the datatype:

SELECT
CAST(CAST(ADD_MONTHS(CURRENT_DATE, 12) AS FORMAT 'yy') AS CHAR(2))
N/A

Re: Manipulating 2-digit year

This worked perfectly, Thanks Fred Pluebell!