%TIME converts the value of the expression from character, numeric, or timestamp data to type time. The converted value remains unchanged, but is returned as a time.
- The first parameter is the value to be converted. If you do not specify a value, %TIME returns the current system time.
- The second parameter is the time format for numeric or character input. Regardless of the input format, the output is returned in *ISO format.
d $time_a s 8a d $time_n s 6s 0 inz(121501) d $time_hms s 8a inz('16:23:01') d $time_usa s 8a inz('04:23 PM') /free //Current Time in *ISO $time_a = %char(%time():*ISO); dsply $time_a; //Current Time in *HMS $time_a = %char(%time():*HMS); dsply $time_a; //Current Time in *USA $time_a = %char(%time():*USA); dsply $time_a; //Numeric Time to *ISO $time_a = %char(%time($time_n):*ISO); dsply $time_a; //Numeric Time to *HMS $time_a = %char(%time($time_n):*HMS); dsply $time_a; //Numeric Time to *USA $time_a = %char(%time($time_n):*USA); dsply $time_a; //*HMS to *ISO $time_a = %char(%time($time_hms:*hms):*ISO); dsply $time_a; //*HMS to *USA $time_a = %char(%time($time_hms:*hms):*USA); dsply $time_a; //*USA to *ISO $time_a = %char(%time($time_usa:*usa):*ISO); dsply $time_a; //*USA to *HMS $time_a = %char(%time($time_usa:*usa):*HMS); dsply $time_a; //Add Hours $time_a = %char((%time($time_usa:*usa) + %hours(2)):*HMS); dsply $time_a; //Add Minutes $time_a = %char((%time($time_usa:*usa) + %minutes(10)):*HMS); dsply $time_a; //Add Seconds $time_a = %char((%time($time_usa:*usa) + %seconds(15)):*HMS); dsply $time_a; //Substract Hours $time_a = %char((%time($time_usa:*usa) + %hours(-2)):*HMS); dsply $time_a; //Substract Minutes $time_a = %char((%time($time_usa:*usa) + %minutes(-10)):*HMS); dsply $time_a; //Substract Seconds $time_a = %char((%time($time_usa:*usa) + %seconds(-15)):*HMS); dsply $time_a; /end-free c eval *inlr = *on
Time formats and separators for Time data type
RPG Format Name | Description | Format (Default Separator) | Valid Separators | Length | Example |
---|---|---|---|---|---|
*HMS | Hours:Minutes:Seconds | hh:mm:ss | : . , & | 8 | 14:00:00 |
*ISO | International Standards Organization | hh.mm.ss | . | 8 | 14.00.00 |
*USA | IBM USA Standard. AM and PM can be any mix of upper and lower case. | hh:mm AM or hh:mm PM | : | 8 | 02:00 PM |
*EUR | IBM European Standard | hh.mm.ss | . | 8 | 14.00.00 |
*JIS | Japanese Industrial Standard Christian Era | hh:mm:ss | : | 8 | 14:00:00 |
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.