View previous topic :: View next topic
|
Author |
Message |
rasha
New User
Joined: 16 Mar 2005 Posts: 7
|
|
|
|
Hi ,
In my table I have timestamp field (ABCD) . I will get date(Char 10) as input ( its a Pl/1 program).
Now i have to compare this input date with timestamp field
i.e. first 10 chars of Timestamp with the input date.
For instance , Timestamp - 2008-01-16--08.39.21.480239
and Input date - 2008-01-16 . so first 10 of timestamp(2008-01-16) is to be compared with input date and if it is equal i have to fetch the records.
I tried for the above in the following manner
1) I used substr(ABCD,1,10) = :input
but i got message as ABCD is not a char field
2) I used Date fucntion which gives date in format 16 Janauary 2008.
But while converting input as wk_input = date(input).
I am getting error as 'Excess arguments for DATE built-in ignored'
Pls let me know how can I get first 10 of timestamp to compare with Input field .
Thanks in advance,
Rasha |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
timestamp is a type date/time field. substring works with characters.
so,
cast abcd to a character string and then use the substr. |
|
Back to top |
|
|
RADHA SRAVANTHI
New User
Joined: 24 Nov 2007 Posts: 1 Location: BANGALORE
|
|
|
|
Hi,
You can use CHAR(DATE(TIMESTAMP)) OR
as you used above substr(char(ABCD),1,10) = :input
I think this should work
Thanks, |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
When you ask for the CHAR version of a date or timestamp you should specify the format. CHAR(DATE, ISO) will give it in YYYY-MM-DD format, the default could be different depending on what is specified when DB2 is installed. |
|
Back to top |
|
|
rasha
New User
Joined: 16 Mar 2005 Posts: 7
|
|
|
|
its working.. Thanks a lot....... |
|
Back to top |
|
|
Ashsih
New User
Joined: 20 Dec 2007 Posts: 29 Location: India
|
|
|
|
Which one is worked
out of given 3 CHAR(DATE(TIMESTAMP)) or substr(char(ABCD),1,10) = :input or CHAR(DATE, ISO)
Also casting is possible in COBOl. |
|
Back to top |
|
|
|