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

Time stamp and Date comparision


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

New User


Joined: 16 Mar 2005
Posts: 7

PostPosted: Mon Jan 28, 2008 7:48 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jan 28, 2008 7:55 pm
Reply with quote

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
View user's profile Send private message
RADHA SRAVANTHI

New User


Joined: 24 Nov 2007
Posts: 1
Location: BANGALORE

PostPosted: Mon Jan 28, 2008 7:57 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jan 28, 2008 8:39 pm
Reply with quote

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
View user's profile Send private message
rasha

New User


Joined: 16 Mar 2005
Posts: 7

PostPosted: Mon Jan 28, 2008 8:55 pm
Reply with quote

its working.. Thanks a lot.......
Back to top
View user's profile Send private message
Ashsih

New User


Joined: 20 Dec 2007
Posts: 29
Location: India

PostPosted: Tue Jan 29, 2008 1:02 pm
Reply with quote

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
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top