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

Posted on 2012-08-21
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

    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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now