If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > getting current time in SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-07, 11:21
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
getting current time in SQL

How can we get current time stamp along with rest of SQl values.


Ex:

Time col1 col2 col3

timestamp abc 243920842 kclsjd
timestamp dsfd 324343335 fghfdf
Reply With Quote
  #2 (permalink)  
Old 11-09-07, 11:37
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
please some body can help me out???
Reply With Quote
  #3 (permalink)  
Old 11-09-07, 11:48
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
got it

-- Date
SELECT current date
FROM sysibm.sysdummy1;

-- Time
SELECT current time
FROM sysibm.sysdummy1;

-- Date-Time
SELECT current timestamp
FROM sysibm.sysdummy1
Reply With Quote
  #4 (permalink)  
Old 11-09-07, 11:49
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
select current timestamp ,rtrim(tabname),card from sysibm.sysdummy1 a,syscat.tables b where b.tabname in ('t1_OLD','t2_OLD');
Reply With Quote
  #5 (permalink)  
Old 11-09-07, 12:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Remove the bogus "sysibm.sysdummy1" from your query. This join doesn't do anything in your case.
Code:
SELECT current timestamp AS timestamp,
       RTRIM(tabname) AS table_name,
       card
FROM   syscat.tables
WHERE  tabname IN ( 't1_OLD', 't2_OLD' )
Note that table names in the catalog views (like SYSCAT.TABLES) are case-sensitive. You must have used delimited identifiers in the table for you query to work, i.e.
Code:
CREATE TABLE "t1_OLD" ( ... )
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On