time from string
Moderators: chulett, rschirm, roy
time from string
Hi guys,
I have the time coming in a string format. eg
12:31:32 is coming in as 123132000. Is there a function or routine in DS which reads in this string and gives me the output 12:31:32.000
Thanks guys.
I have the time coming in a string format. eg
12:31:32 is coming in as 123132000. Is there a function or routine in DS which reads in this string and gives me the output 12:31:32.000
Thanks guys.
Instead of using the ICONV/OCONV I think your easiest solution is to use
Code: Select all
In.Column[1,2]:':':In.Column[3,2]:':':In.Column[5,2]:'.':In.Column[7.3]
Last edited by ArndW on Tue Feb 28, 2006 11:32 am, edited 1 time in total.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
amsh76
the ICONV/OCONV for the MT only works if i have the time in the actual time format. (either one of the few listen in the server manual) my problem is with the way the time is coming in. Its in a string format, the ICONV/OCONV functions spit out a 0 if i feed in a time that coming in the format i specified.
if you have a way to do this, please let me know (i mean using ICONV/OCONV)
thanks
the ICONV/OCONV for the MT only works if i have the time in the actual time format. (either one of the few listen in the server manual) my problem is with the way the time is coming in. Its in a string format, the ICONV/OCONV functions spit out a 0 if i feed in a time that coming in the format i specified.
if you have a way to do this, please let me know (i mean using ICONV/OCONV)
thanks
Add an IF-THEN-ELSE statement that checks for LEN(In.Column)=8 or explicitly format the column to 9 places padding on the left; i.e. FMT(In.Column,'9"0"R')
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
Hi,
You can also build a custom routine with the statements and method as suggested by ArndW and Amit.
Passing just the input string as Agr1 to the routine as below:
And now you can use this routine anywhere, anytime you like.
Thanks,
Whale.
You can also build a custom routine with the statements and method as suggested by ArndW and Amit.
Passing just the input string as Agr1 to the routine as below:
Code: Select all
FUNCTION StringToTimestamp(Arg1)
Code: Select all
x = Fmt(Arg1,'9"0"R')
Ans = x[1,2]:':':x[3,2]:':':x[5,2]:'.':x[7,3]
Code: Select all
RETURN(Ans)
Thanks,
Whale.
Last edited by I_Server_Whale on Thu Jan 25, 2007 4:38 am, edited 1 time in total.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
Yes! It would be the best idea to use a routine for the reason that it can be re-used anywhere and anytime. But if you are like 110% sure that you would never need such functionality again (which I doubt ), then there is no need to build a routine for a one-time case.
And you are Welcome!
Whale.
And you are Welcome!
Whale.
Last edited by I_Server_Whale on Thu Jan 25, 2007 4:38 am, edited 1 time in total.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE