IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

I need to change the date Format to yyyymmdd from MM/DD/YYYY


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gangwarnidhi

New User


Joined: 20 Nov 2006
Posts: 4
Location: Delhi

PostPosted: Tue Apr 27, 2010 2:34 pm
Reply with quote

Hi! This is your First post in our Forums! So please be sure to 1) Use meaningful and descriptive Topic Title 2) Try to post your query in the relevant forum category 3) Make sure your query is not already posted and solved in our forums, Use the Search facility and avoid Reposts! If you are following the above rules, delete this message and post your query here!

query is:
SELECT A1
FROM table 1
WHERE A1 BETWEEN
DATE(SUBSTR(CHAR(CURRENT DATE,ISO),1,10))
- 36 MONTHS
AND DATE(SUBSTR(CHAR(CURRENT DATE,ISO),1,10))
- 1 DAY

Please suggest the needful

----
Anakshi
Back to top
View user's profile Send private message
gangwarnidhi

New User


Joined: 20 Nov 2006
Posts: 4
Location: Delhi

PostPosted: Tue Apr 27, 2010 2:35 pm
Reply with quote

the output of the query is coming in format MM/DD/YYYY
I need in YYYYMMDD
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Apr 27, 2010 2:39 pm
Reply with quote

Hello Nidhi,

Welcome to the forum.

Please refer below link might be useful for u

www.ibm.com/developerworks/data/library/techarticle/0211yip/0211yip3.html?S_TACT=105AGX01&S_CMP=TOPTEN
Back to top
View user's profile Send private message
gangwarnidhi

New User


Joined: 20 Nov 2006
Posts: 4
Location: Delhi

PostPosted: Tue Apr 27, 2010 2:42 pm
Reply with quote

Thanks for replying...
Sorry!! I guess it is not useful to me if you can suggest something better than tht is really gud....

----
Anakshi
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Apr 27, 2010 3:06 pm
Reply with quote

Do you have any clue what this does :

DATE(SUBSTR(CHAR(CURRENT DATE,ISO),1,10))

It takes the current date
- turns it into characters
- takes the 10 leftmost character (it is always 10 characters long to begin with)
- and then turns it back to a date format
giving exactly the same as

current date

Someone who writes something like this should be restrained from writing any further SQL (or any other computer language for that matter)


and as for an answer to your question :
it depends on a zparm, the data type of A1 , the version of your DB2.

in V9 NFM you can use : varchar_format(timestamp(A1,'00:00:00'),'YYYYMMDD')

earlier versions : you have to help yourself with the functions described in the link guptae posted.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 27, 2010 8:47 pm
Reply with quote

Hello,

Quote:
Sorry!! I guess it is not useful to me if you can suggest something better than tht is really gud....
If it is not useful to you, you need to go back and review . . .

What would have been "better". . . icon_confused.gif
Back to top
View user's profile Send private message
gangwarnidhi

New User


Joined: 20 Nov 2006
Posts: 4
Location: Delhi

PostPosted: Wed Apr 28, 2010 10:21 am
Reply with quote

I did it ... Thanks for ur help.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 28, 2010 7:29 pm
Reply with quote

You're welcome - thank you for the update icon_smile.gif

It will probably help someone else some day if you post your solution. . .

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top