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
 

 

To select records from the table from time stamp column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
rashmirgowda

New User


Joined: 18 Jun 2008
Posts: 25
Location: india

PostPosted: Thu Jul 29, 2010 3:16 pm    Post subject: To select records from the table from time stamp column
Reply with quote

Hi,

I am having a table TABLE A, one of the column is timestamp.I want to select records based on the date which is present in timestamp.I will be passing only date as input to the query.

select *
from TABLE A
where DATE(timestamp column) = '2010-06-21'

I have used this above query and not able to select the records.Please help in selecting the records.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jul 29, 2010 3:35 pm    Post subject:
Reply with quote

well, putting a scalar function on every row is not very efficient.

i would instead:

where timestamp_column between timestamp('2010-06-21', '00.00.00') and
timestamp('2010-06-21', '23.59.59')

the above format may or may not work on your version of db2,
nor have I tested it, because I don't have the time.
This would be good experience for you.
suggest you work in spufi until you are able to generate accurate timestamps

SELECT timestamp('2010-06-21', '00.00.00')
, timestamp('2010-06-21', '23.59.59')
from sysibm.sysdummy1

until that works.
then substitute the proper format/syntax of the timestamp('2010-06-21', '00.00.00')
in your basic sql.

addressing your original question,
if you had an sqlcode of 0, that means you do not have any rows
containing a timestamp within the date.

if you had an sqlcode <> 0, then say so.

probably would be a good idea if you
SELECT *
from tablea
fetch first 10 rows only
to see what valid dates exists, then construct your select with timestamp
for an existing date.
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts DD DUMMY & CPU TIME Nileshkul Testing & Performance analysis 16 Mon Dec 19, 2016 11:35 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm


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