Skip to main content
Aug 31, 2021 9:20 AM UTC
Question

Time conversion to HHMMSS without colon seperators

All,

Running UniVerse 11.3.1 on Redhat.

I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

Jon

    8 replies

    David Green
    Inspiring
    Aug 31, 2021 12:50 PM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon

    In UniData you can put multiple conversion codes is a single OCONV separated by @VM.

     

    YYYYMMDD = OCONV(@DATE, “DYMD”:@VM:”MCN”)

     HHMMSS = OCONV(@TIME, "MTHS":@VM:"MCN")

    Just curious if this helps you.

     

    David

    Aug 31, 2021 2:00 PM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    David,

    Thanks, I was aware of that. Just looking for the most efficient way of getting HHMMSS without multiple conversions. I don't understand the documentation when is shows what looks like the date format string, but I can't get it to work at all. Just returns the internal time with milliseconds. I did not look at the STATUS() but I'm sure it says I am in error.
    Neil Morris
    Rocketeer
    Aug 31, 2021 5:50 PM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    Hi Jon,
    I will need to investigate some more. I tried using the syntax to replace the ":" delimiter with another character (including the empty string) and the conversion fails. It returns the internal time and the STATUS() is set to 2.

    >COPYP BP JON (TSN

    JON
    CRT OCONV(@TIME,"MTHS'='")
    CRT STATUS()
    END
    >RUN BP JON
    57219
    2
    >
    I will let you know what I find.

    Thanks,

    Neil
    Mike Bojaczko
    Participating Frequently
    Aug 31, 2021 6:20 PM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    Im not that good but here goes...

    TIM: 00:25: ITIM: 1500

    002500

    OCONV(1500,'MTS'):             00:25:00        STATUS:0

    OCONV(1500,'MTS_'):            00_25_00        STATUS:0

    OCONV(1500,'MTS{'):            00{25{00        STATUS:0

    OCONV(1500,'MTH'):             12:25am         STATUS:0

    OCONV(1500,'MTP'):             am12:25         STATUS:0

    OCONV(1500,'MTZ'):             0:25            STATUS:0

    OCONV(1500,'MTS["","",""]'):   002500          STATUS:0

     

    TIM: 16:25: ITIM: 59100

    OCONV(59100,'MTS'):             16:25:00        STATUS:0

    OCONV(59100,'MTS_'):            16_25_00        STATUS:0

    OCONV(59100,'MTS{'):            16{25{00        STATUS:0

    OCONV(59100,'MTH'):             04:25pm         STATUS:0

    OCONV(59100,'MTP'):             pm04:25         STATUS:0

    OCONV(59100,'MTZ'):             16:25           STATUS:0

    OCONV(59100,'MTS["","",""]'):   162500          STATUS:0

    > 

    Neil Morris
    Rocketeer
    Sep 1, 2021 6:47 AM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    Thanks Mike.  It looks like the documentation may be in error as it indicates the delimiter character should be enclosed in quotes. However, it looks like it works as expected when quotes are not used.
    Sep 1, 2021 8:11 AM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    Mike,

    Huzzah! Thank you Mike. Just what I was looking for. Documentation could use a bit of improvement here. Many thanks!

    Jon
    Mike Bojaczko
    Participating Frequently
    Sep 1, 2021 8:46 AM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    Thanks Neil and Jon!

    Also, I am not using NLS and I am using Information flavor.
    Mike Bojaczko
    Participating Frequently
    Sep 1, 2021 10:44 AM UTC
    All,

    Running UniVerse 11.3.1 on Redhat.

    I have been using the data conversion OCONV(DATE(),"DYMD[4'',2'',2]" then the 4'' (2-single quotes) and 2'' (2-single quotes) provides the date in YYYYMMDD without dashed or slashes.  Works great.

    The BASIC Manual Page 533 shows MT [H] [P] [Z] [S] [c] [[f1, f2, f3]]. I've tried different variations of "MTS''[2,2,2]" (S'' is two single quotes). Is there a way to convert a time into HHMMSS without using a second function to strip away the ':'s.

    Jon
    My original tests were outputing the status of 'L#15' instead of OCONV. So, ran new tests without the formating command.

    In regards to the documentation...My second page of my TCL HELP CONV MT output is worded like my 11.2.5 UV Basic User Guide pdf. In the pdf on page C-42 second paragraph, second sentence says "Enclose the separator...". If using "c", it is in quotes if after MT like 'MT.' .If using the format modifier, the separators must be in quotes to override the  "c" parameter or the default separator, or it fails...I think. So, some documentation examples might be the easiest way to clarify things.

     Below us another set of tests.. 

    TIME TEST 2 CODE AND OUTPUT:

    TIM: 00:25: ITIM: 1500

    '1. ':OCONV(ITIM,'MT.')                   1.  00.25 STATUS:0

    '2. ':OCONV(ITIM,'MTS.')                  2.  00.25.00 STATUS:0

    '3. ':OCONV(ITIM,'MTS{')                  3.  00{25{00 STATUS:0

    '4. ':OCONV(ITIM,'MTS-,[".",".","."]')    4.  1500 STATUS:2

    '5. ':OCONV(ITIM,'MTS"-",[".",".","."]')  5.  1500 STATUS:2

    '6. ':OCONV(ITIM,'MTS-,[.,".","."]')      6.  1500 STATUS:2

    '7. ':OCONV(ITIM,'MTS,[.,".","."]')       7.  1500 STATUS:2

    '8. ':OCONV(ITIM,'MTS,[,".",]')           8.  00,25.00 STATUS:0

    '9. ':OCONV(ITIM,'MTS-,[,".",]')          9.  1500 STATUS:2

    '10. ':OCONV(ITIM,'MTS[,".",]')           10. 00:25.00 STATUS:0

    '11. ':OCONV(ITIM,'MTS}[,".",]')          11. 00}25.00 STATUS:0

    > 

    Thanks