I recently started using DB2 after years of using Oracle. There are a few functions I used a lot in Oracle that I'm struggling to find equivalents of in DB2.
a) Is there a function which pads a string with a given character either on the right or the left (lpad/rpad in Oracle) e.g.
select lpad('9', 5, '0') gives '000009'
select rpad('9', 5, '0') gives '900000'
I suppose I could contrive something using REPEAT and concatenate but that seems like hard work.
b) Is there a function which converts dates to strings and vice versa ? I know there is a date function but this only recognises certain formats. For example, if I try to pass a date in a format such as YYYYMMDD rather than YYYY-MM-DD, it doesn't like it. Is there one where you can specify the format you would like the date to appear in ?
a) Is there a function which pads a string with a given character either on the right or the left (lpad/rpad in Oracle) e.g.
select lpad('9', 5, '0') gives '000009'
select rpad('9', 5, '0') gives '900000'
I suppose I could contrive something using REPEAT and concatenate but that seems like hard work.
b) Is there a function which converts dates to strings and vice versa ? I know there is a date function but this only recognises certain formats. For example, if I try to pass a date in a format such as YYYYMMDD rather than YYYY-MM-DD, it doesn't like it. Is there one where you can specify the format you would like the date to appear in ?