ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Time Conversion

Post new topic  Reply to topic
 Time Conversion « View previous topic :: View next topic » 
Author Message
Deepak.k
PostPosted: Fri Aug 26, 2016 10:52 pm    Post subject: Time Conversion Reply with quote

Novice

Joined: 18 Aug 2016
Posts: 22

Hi guys

I have a problem regarding date conversion, I have field in dfdl where the data of the filed may be
1.DDMMYYYY
2.DDMMMYYYY
3.DDMONTHYYYY

The ultimate is to change these date into 'DDMONYYYY',and set to that field.
I have try things like getting length of that and making it is there any other process other this.

Here is the code i had try
Declare dte character;
Set dte = inputroot.dfdl.*.header.date;

DECLARE get,first,lst CHARACTER;
SET first =SUBSTRING(dte FROM 1 FOR 2);
SET get = SUBSTRING(dte FROM 3 FOR 2);
SET lst = SUBSTRING(dte FROM 7 FOR 2);

IF get='01' THEN
SET get ='JAN';

ELSEIF get='02' THEN
SET get ='FEB';

ELSEIF get='03' THEN
SET get ='MAR';

ELSEIF get='04' THEN
SET get ='APR';

ELSEIF get='05' THEN
SET get ='MAY';

ELSEIF get='06' THEN
SET get ='JUN';

ELSEIF get='07' THEN
SET get ='JUL';

ELSEIF get='08' THEN
SET get ='AUG';

ELSEIF get='09' THEN
SET get ='SEP';

ELSEIF get='10' THEN
SET get ='OCT';

ELSEIF get='11' THEN
SET get ='NOV';

ELSEIF get='12' THEN
SET get ='DEC';
END IF;


waiting for ur reply's
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Aug 26, 2016 11:10 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Can't the DFDL Parser handle this all for you?
I think it can but I'm not positive

However two things jump out at me from your code
Code:

Set dte = inputroot.dfdl.*.header.date;


So you have never tried to run this ESQL then?

As for the IF... ELSEIF.... END,
Use a Case statement.

I am sure that there are other ways to do this.
Personally, I'd look at using the DFDL parser to determine the format and output a timestamp. This can then be cast to a CHAR with a format that describes the output format that you need.
_________________
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
View user's profile Send private message
fjb_saper
PostPosted: Sat Aug 27, 2016 5:15 am    Post subject: Re: Time Conversion Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Deepak.k wrote:
Hi guys

I have a problem regarding date conversion, I have field in dfdl where the data of the filed may be
1.DDMMYYYY
2.DDMMMYYYY
3.DDMONTHYYYY

The ultimate is to change these date into 'DDMONYYYY',and set to that field.
I have try things like getting length of that and making it is there any other process other this.

waiting for ur reply's


For the output that should be fairly easy...
For the input... Have you tried a DFDL choice statement with the different format set on each branch of the choice?

Of course you will have to look at discriminators as well. Should not be too hard with only 12 values for each... and start with the longest first ...
I know that if the date was current, I'd be testing for the value of the current year...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mpong
PostPosted: Mon Aug 29, 2016 10:55 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

Code:
DECLARE get,first,lst CHARACTER;
SET first =SUBSTRING(dte FROM 1 FOR 2);
SET get = SUBSTRING(dte FROM 3 FOR 2);
SET lst = SUBSTRING(dte FROM 7 FOR 2);


If you are keen on implementing thru ESQL, I suggest you to find the length of a input string before you write SUBSTRING function. Something like below

Code:
Set dte = inputroot.dfdl.*.header.date;

DECLARE inlength INTEGER;
SET inlength =LENGTH(dte);
IF inlength =8 then

--Based on the length, you can determine the output format.

ELSEIF inlength =9 THEN 

ELSEIF inlength =11 THEN

END IF;
Back to top
View user's profile Send private message
timber
PostPosted: Tue Aug 30, 2016 1:46 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

@mpong: Your code tags didn't work. Not sure why not.

I agree with smdavies99 and fjb_saper. You *could* do this using a choice of 3 xs:date elements, each with a different name and a different calendarPattern property. If the data format does not match the first member of the choice then DFDL should move onto the second member etc.

However, if I was doing this I would probably model the field as xs:string and check the length. Then use CAST with a PATTERN to convert to a GMTTIMESTAMP and finally CAST to CHARACTER to get the desired output format.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Time Conversion
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.