Is there a function in DB2 as400 that masks a string or number?

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-22
Is there a function in DB2 as400 that masks a string or number?
in exemple,
I have the NUMBER= 20120821

I would like a function: masks( NUMBER, '9999-99-99') that returns a string = 2012-08-21

This because I have a field decimal 8,0 (YYYYMMDD, ISO)
and I have to traslate it in a date field


Release as400 V5R4M0
Question by:bobdylan75
1 Comment
LVL 37

Accepted Solution

momi_sabag earned 2000 total points
ID: 38315545
no such function, but you can write it yourself:
select substr(char(your_dec_field),1,4)||'-'||substr(char(your_dec_field),5,2)||';'||substr(char(your_dec_field),7,2)
from your_table

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question