Bear Bibeault wrote:Seems a simple enough exercise to separate the digits into groups of two, what's the issue that's holding you up?
Steve Dyke wrote:From remote data I get a number like 70000 or 4321...
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Steve Dyke wrote:From remote data I get a number like 70000 or 4321...
May I ask why? If this is just a classroom exercise, then fine; but if not, there are already established standards out there for passing date/time values, such as ISO 8601, and your "provider" would probably do well to use them.
And you might even get brownie points for suggesting it.
Winston
Steve Dyke wrote:Probably so simple I can't see it. You know the old adage can't see forest for trees.
Is there a way to just format 70000 or 4921 into a time format HH:mm:ss?
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Steve Dyke wrote:Probably so simple I can't see it. You know the old adage can't see forest for trees.
Is there a way to just format 70000 or 4921 into a time format HH:mm:ss?
Well, take one of them to start with: 4921.
First question: Does your "format" allow that to be hh:mm, or does it have to be mm:ss? Because if it's the first, it probably won't work.
Which is just another reason to use existing standards.
But let's suppose it is mm:ss  how would YOU break it up?
Hint: Imagine it's the number 4,921. How would you get (a) the '49' and (b) the '21' out of that?
It really is very simple; and you'll be much happier if you work it out for yourself.
Winston
Steve Dyke wrote:My data is coming from and going into an iSeries(AS400) database the time field for transactions is stored as a max 6 digit number.
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Steve Dyke wrote:The max 6 digit number will have to work from right to left due to the fact the hour portion can be 1 or two digits. 4921 is 49 minutes, 21 seconds while 70000 is 7 hours, 0 minutes, 0 seconds
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Steve Dyke wrote:The max 6 digit number will have to work from right to left due to the fact the hour portion can be 1 or two digits. 4921 is 49 minutes, 21 seconds while 70000 is 7 hours, 0 minutes, 0 seconds
OK, so assuming this is a number and not a string, how would you get 49 from 4,921?
Winston
Steve Dyke wrote:If it was a string I would use substring method. But I know this will not work on a number. Do I convert to number first or are there methods like such for numbers?
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Steve Dyke wrote:If it was a string I would use substring method. But I know this will not work on a number. Do I convert to number first or are there methods like such for numbers?
You're overthinking this. It's a number. So how do you get the last two decimal digits of a number? Or indeed, the ones before the last two digits?
How do you know if a number contains more than 4 decimal digits?
Forget 4921 and try 7,694. How would you do it then?
Winston
Steve Dyke wrote:
Winston Gutkowski wrote:Another question: Is this an SQL database (eg, DB2)? Because if so, you can almost certainly import it as a java.sql.Date.
Steve Dyke wrote:This what I came up with and it works. But is the correct way?
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Remember to always leap before you look. But always take the time to smell the tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/GardenMasterkickstarter
