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 » Date Casts

Post new topic  Reply to topic
 Date Casts « View previous topic :: View next topic » 
Author Message
dmw1986
PostPosted: Mon Nov 17, 2008 11:49 am    Post subject: Date Casts Reply with quote

Apprentice

Joined: 24 Sep 2008
Posts: 35

Is there a way using the mapping node to strip off dashes in a date. We are being sent 9999-12-31 but our COBOL include and database only accepts 99991231. Thanks
Back to top
View user's profile Send private message
sridhsri
PostPosted: Mon Nov 17, 2008 1:01 pm    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

I would recommend using MRM to convert between date formats and not using Mapping functions for this.

But if you had to use them, there are getyear, getmonth etc function and you'd have to use string concat function to create a date in the format you need. I strongly recommend using MRM for this though.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Nov 17, 2008 1:28 pm    Post subject: Reply with quote

Grand High Poobah

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

sridhsri wrote:
I would recommend using MRM to convert between date formats and not using Mapping functions for this.

But if you had to use them, there are getyear, getmonth etc function and you'd have to use string concat function to create a date in the format you need. I strongly recommend using MRM for this though.

Since version 6 you have a cast with format for date, time(?) and datestamp type values.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
dmw1986
PostPosted: Mon Nov 17, 2008 1:43 pm    Post subject: Reply with quote

Apprentice

Joined: 24 Sep 2008
Posts: 35

I'll try to be a little more specific, I may have confused you.

The message is coming in XML form such as

<nc:PersonBirthDate>
<nc:Date>1966-01-23</nc:Date>
</nc:PersonBirthDate>

My COBOL Include is only 8 long so I just need to strip the dashes to make it 19660123.

Can I do that in the mapping node?

Thanks for your rersponses, much appreciated.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Nov 17, 2008 2:11 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.

You can easily do it in ESQL using a CAST to a FORMAT.

Lookup the syntax in the WBI Help and you will see what I mean.

Otherwise, set the output form in the output Message set to be YYYYMMDD
_________________
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
kimbert
PostPosted: Mon Nov 17, 2008 2:28 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
My COBOL Include is only 8 long so I just need to strip the dashes to make it 19660123.
Can I do that in the mapping node?
It probably is possible. But I agree with sridhsri - this is what the MRM parser is provided for. If you are not using MRM, why not?
Back to top
View user's profile Send private message
dmw1986
PostPosted: Tue Nov 18, 2008 10:28 am    Post subject: Reply with quote

Apprentice

Joined: 24 Sep 2008
Posts: 35

I took up your ideas and am using MRM now. However for some reason the ESQL doesnt like my syntax. Can you help me? I've tried both YYYY and CCYY within my format but it says "CCYYMMDD" Cannot be Resolved.

Code:
SET OutputRoot.MRM.CJ37CI80_INPUT_DATA.CJ37CI80_DOB = CAST(InputRoot.XMLNSC.mo_warrant:Warrant.mo_warrant:Person.nc:PersonBirthDate.nc:Date AS DATE FORMAT "CCYYMMDD");
Back to top
View user's profile Send private message
dmw1986
PostPosted: Tue Nov 18, 2008 10:47 am    Post subject: Reply with quote

Apprentice

Joined: 24 Sep 2008
Posts: 35

Edit, Nevermind still not working. Was able to deploy but still not stripping dashes.

SET OutputRoot.MRM.CJ37CI80_INPUT_DATA.CJ37CI80_DOB = CAST(InputRoot.XMLNSC.mo_warrant:Warrant.mo_warrant:Person.nc:PersonBirthDate.nc:Date AS CHARACTER FORMAT 'yyyyMMdd');
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Nov 18, 2008 2:05 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

hi dmw1986,
Quote:
Was able to deploy but still not stripping dashes
You need to set the date format used by this field. You can do that in either of two places:
-at the message set level, where it will apply to all date and/or time fields in your message
- on the CWF properties of the field itself

re: this
Code:
CAST(InputRoot.XMLNSC.mo_warrant:Warrant.mo_warrant:Person.nc:PersonBirthDate.nc:Date AS CHARACTER FORMAT 'yyyyMMdd')
You should not need to convert a string to a date in your ESQL. The parser can do that for you, as detailed below:

If necessary ( i.e. if the input logical structure is different from the output logical structure ) create another message definition to describe the input message.

If you are on v6.1:
- XMLNSC can create all the data types in the message tree.
- you must specify the message set in the input node properties
- you must set validation to 'Content and Value'
- you must enable the Parser Property 'Build tree using XML Schema'

If on v6.0 or earlier:
- MRM can create all the data types in the message tree.
- create an XML physical format in your existing message set.
- remember to specify the correct Message Type in the input node properties
- remember to set the Message Format to 'XML1' or whatever name you chose for your physical format
Back to top
View user's profile Send private message
broker_new
PostPosted: Tue Nov 18, 2008 5:02 pm    Post subject: Reply with quote

Yatiri

Joined: 30 Nov 2006
Posts: 614
Location: Washington DC

I agree with sridhsri to use MRM parser for time,date related castings.

I faced one problem when casting timestamp.
Broker(6.0.3) was not considering the DST when using XMLNS,XMLNSC where MRM fixed it.
_________________
IBM ->Let's build a smarter planet
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 » Date Casts
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.