Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Validate the Date girishb2 DFSORT/ICETOOL 9 Tue Sep 19, 2017 1:12 am
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us