Author |
Message
|
Vamsi Krishna |
Posted: Sun Jul 06, 2014 10:46 pm Post subject: Changing Pattern For Timestamp |
|
|
 Acolyte
Joined: 12 May 2014 Posts: 53
|
Hi, anyone can tell me how can I convert timestamp msg
2014-07-07T09:27:52.418968
to 20140707T0927 In Integration Bus
Using Cast function is it possible that we can perform like this
Anyone Please help |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Jul 06, 2014 10:58 pm Post subject: Re: Changing Pattern For Timestamp |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Vamsi Krishna wrote: |
Hi, anyone can tell me how can I convert timestamp msg
2014-07-07T09:27:52.418968
to 20140707T0927 In Integration Bus
Using Cast function is it possible that we can perform like this
Anyone Please help |
First you need to make sure the data is correctly read as a timestamp/GMTTIMESTAMP.
Then use a cast with format... or just define the outgoing format in xml / dfdl and have the broker apply at serialization...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vamsi Krishna |
Posted: Sun Jul 06, 2014 11:01 pm Post subject: |
|
|
 Acolyte
Joined: 12 May 2014 Posts: 53
|
Thanks but i tried to use fromat but the time stamp is not changing can i have a code to perform this iam new to Integration bus |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Jul 06, 2014 11:05 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Vamsi Krishna wrote: |
Thanks but i tried to use fromat but the time stamp is not changing can i have a code to perform this iam new to Integration bus |
Please show us what code you tried to use. That way we can help you to help yourself. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vamsi Krishna |
Posted: Sun Jul 06, 2014 11:08 pm Post subject: |
|
|
 Acolyte
Joined: 12 May 2014 Posts: 53
|
This is my code
DECLARE pattern CHARACTER 'yyyyMMdd''T''hmm';
DECLARE A CHARACTER InputRoot.XMLNSC.Trans.In;
SET OutputRoot.XMLNSC.Trans.C_time = CAST(A AS GMTTIMESTAMP FORMAT pattern);
and I have taken "20140707T0927" as character Input and i want to print it as TIMESTAMP or GMTTIMESTAMP with same Output "20140707T0927" |
|
Back to top |
|
 |
Vamsi Krishna |
Posted: Sun Jul 06, 2014 11:24 pm Post subject: |
|
|
 Acolyte
Joined: 12 May 2014 Posts: 53
|
smdavies99 wrote: |
Vamsi Krishna wrote: |
Thanks but i tried to use fromat but the time stamp is not changing can i have a code to perform this iam new to Integration bus |
Please show us what code you tried to use. That way we can help you to help yourself. |
This is my code
DECLARE pattern CHARACTER 'yyyyMMdd''T''hmm';
DECLARE A CHARACTER InputRoot.XMLNSC.Trans.In;
SET OutputRoot.XMLNSC.Trans.C_time = CAST(A AS GMTTIMESTAMP FORMAT pattern);
and I have taken "20140707T0927" as character Input and i want to print it as TIMESTAMP or GMTTIMESTAMP with same Output "20140707T0927" |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Jul 07, 2014 12:23 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
ok, you are halfway there.
If we assume that
1) InputRoot.XMLNSC.Trans.In is a CHARACTER (xs:string) datatype and has a value of '2014-07-07T09:27:52.418968 '
2) OutputRoot.XMLNSC.Trans.C_time is also a CHARACTER datatype
3) You want to output C_tim in the format 'yyyyMMdd''T''hmm'
Then
1) The casting of the Input 'Trans.In' will need a format description all of its own
2) To keep it simple as you are learing, the ncast the input to a GMTTIMESTAMP varianle, then cast that to a CHAR.
Give it a try. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vamsi Krishna |
Posted: Mon Jul 07, 2014 12:31 am Post subject: |
|
|
 Acolyte
Joined: 12 May 2014 Posts: 53
|
smdavies99 wrote: |
ok, you are halfway there.
If we assume that
1) InputRoot.XMLNSC.Trans.In is a CHARACTER (xs:string) datatype and has a value of '2014-07-07T09:27:52.418968 '
2) OutputRoot.XMLNSC.Trans.C_time is also a CHARACTER datatype
3) You want to output C_tim in the format 'yyyyMMdd''T''hmm'
Then
1) The casting of the Input 'Trans.In' will need a format description all of its own
2) To keep it simple as you are learing, the ncast the input to a GMTTIMESTAMP varianle, then cast that to a CHAR.
Give it a try. |
DECLARE pattern CHARACTER 'yyyyMMdd,T,hhmm';
DECLARE A CHARACTER InputRoot.XMLNSC.Trans.In;
SET OutputRoot.XMLNSC.Trans.C_time = CAST(A AS CHARACTER FORMAT pattern);
I had previously tried with this code and casting it to character Iam getting the desired result as in character
But my requirement is input 20140707T0927 it is a character I want the output in Timestamp or GMTTimetamp with output 20140707T0927 |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Jul 07, 2014 1:47 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Vamsi Krishna wrote: |
But my requirement is input 20140707T0927[/b] it is a character I want the output in Timestamp or GMTTimetamp with output 20140707T0927 |
The FORMAT is for Character datatypes only. The format of a GMTTIMESTAMP or TIMESTAMP is fixed. you can't change that. The cast with a FORMAT tells broker to take the (lets say binary) format of the TIMESTAMP datatypes and create a character string with the format described.
Are you sure that you want OutputRoot.XMLNSC.Trans.C_tim to be a timestamp type data? The name 'c_tim' leads me to think you might want it to be a character type.
In anycase, you will still need to develop a format string to allow you to convert the input format into a Timestamp type. There are some pre-defineds ones that will do it for you.
The InfoCentre has a list of them. Search for 'Formatting and parsing dateTimes as strings' _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
|