View previous topic :: View next topic
|
Author |
Message |
gangwarnidhi
New User
Joined: 20 Nov 2006 Posts: 4 Location: Delhi
|
|
|
|
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 |
|
|
gangwarnidhi
New User
Joined: 20 Nov 2006 Posts: 4 Location: Delhi
|
|
|
|
the output of the query is coming in format MM/DD/YYYY
I need in YYYYMMDD |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
Back to top |
|
|
gangwarnidhi
New User
Joined: 20 Nov 2006 Posts: 4 Location: Delhi
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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". . . |
|
Back to top |
|
|
gangwarnidhi
New User
Joined: 20 Nov 2006 Posts: 4 Location: Delhi
|
|
|
|
I did it ... Thanks for ur help. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - thank you for the update
It will probably help someone else some day if you post your solution. . .
d |
|
Back to top |
|
|
|