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
 

 

Time stamp and Date comparision

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Time stamp and Date comparision
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: 6968
Location: porcelain throne

PostPosted: Mon Jan 28, 2008 7:55 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Time stamp and Date comparision
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    Post subject:
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    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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 5 Sat May 06, 2017 12:59 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts Application not run by time HH:MM tri... jzhardy IBM Tools 1 Sun Apr 09, 2017 3:22 pm


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