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 » CAST YYYY/MM/DD to DD/MM/YYYY

Post new topic  Reply to topic
 CAST YYYY/MM/DD to DD/MM/YYYY « View previous topic :: View next topic » 
Author Message
nukalas2010
PostPosted: Wed Dec 18, 2013 11:22 pm    Post subject: CAST YYYY/MM/DD to DD/MM/YYYY Reply with quote

Master

Joined: 04 Oct 2010
Posts: 220
Location: Somewhere in the World....

Dears,
Code:
Input:-  2013-11-25
Expected Output:- 25/11/2013

Currently tried as below with out CAST..

Code:
DECLARE cPmtDate CHARACTER '2013/11/25';
      
      DECLARE cdate CHARACTER SUBSTRING(cPmtDate FROM 9 FOR 2);
      DECLARE cmon CHARACTER SUBSTRING(cPmtDate FROM 6 FOR 2);
      DECLARE cyear CHARACTER SUBSTRING(cPmtDate FROM 1 FOR 4);
      
      SET Environment.Variables.DateValue = cdate||'/'||cmon||'/'||cyear;

And getting the output as expected, but looking for best way to achieve this..

Can anybody throw some light on this..
Back to top
View user's profile Send private message
Simbu
PostPosted: Thu Dec 19, 2013 12:26 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Hi nukalas2010, Is there any reason for ignoring CAST to achieve this?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Dec 19, 2013 12:29 am    Post subject: Reply with quote

Jedi Council

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

How about casting to a DATE and back again?
{untested code}
Code:


declare c1 char '2013-11-25';
declare d1 DATE;
declare c2 char;

set d1 = cast(c1 as date format 'yyyy-MM-dd');
set c2 = cast(d1 as char format 'dd/MM/yyyy');



Naturally you could do it all on one line.

Last year I inherited a set of flows that did all of its date/time manipulation with the methods you describe. What was worse was that the developer didn't know (or couldn't be bothered) to code up a few functions to do it because they coded in-line the same thing almost a hundred times. They did the same for creating and populating an MQMD.
Rather sad really.
_________________
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
nukalas2010
PostPosted: Thu Dec 19, 2013 12:55 am    Post subject: Reply with quote

Master

Joined: 04 Oct 2010
Posts: 220
Location: Somewhere in the World....

Simbu wrote:
Hi nukalas2010, Is there any reason for ignoring CAST to achieve this?


@ Simbu: First of all, I tried to get this using CAST only. But What I did was to do cast directly from character to date to get that output which was failing and my mind force me to do as mentoned in my post to fix it ASAP and not even get Idea as davies suggested below ...

smdavies99 wrote:
How about casting to a DATE and back again?

@ Davies: Thanks Davies for your smart help which made it easier..
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 » CAST YYYY/MM/DD to DD/MM/YYYY
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.