Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: I need to change the date Format to yyyymmdd from MM/DD/YYYY
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    Post subject:
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: 1187
Location: Bangalore,India

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

Hello Nidhi,

Welcome to the forum.

Please refer below link might be useful for u

http://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    Post subject: Reply to: I need to change the date Format to yyyymmdd from
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    Post subject:
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

Site Director


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

PostPosted: Tue Apr 27, 2010 8:47 pm    Post subject:
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    Post subject: Thank all of you..
Reply with quote

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

Site Director


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

PostPosted: Wed Apr 28, 2010 7:29 pm    Post subject: Reply to: I need to change the date Format to yyyymmdd from
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us