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 > Get Current TimeStamp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-07, 07:06
mabeljovan mabeljovan is offline
Registered User
 
Join Date: Jun 2007
Posts: 27
Get Current TimeStamp

Hi Guys!,

How to get the current timestamp in the whole Database regardless of table.

Thanks,
MabelJovan
Reply With Quote
  #2 (permalink)  
Old 09-05-07, 08:01
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
values (current timestamp)

Andy
Reply With Quote
  #3 (permalink)  
Old 09-05-07, 11:46
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
DB2 z/OS does not yet understand the VALUES table constructor. Then you would do this (works also on LUW):
Code:
SELECT CURRENT TIMESTAMP
FROM   sysibm.sysdummy1
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 09-06-07, 04:19
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
by the way... will IBM ever create DB2 ISO standard compatible way of accessing "current timestamp" variable?

This is important if you write a program to multiple databases (DB2, Oracle, MySQL etc). To have only one SQL code instead of multiple SQL code and multiple program versions.

More info about current timestamp and IBM implementation:
http://troels.arvin.dk/db/rdbms/#dat...time-timestamp

Thanks,
Grofaty
Reply With Quote
  #5 (permalink)  
Old 09-06-07, 04:50
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What exactly do you mean with "ISO standard compatible way"?

You can query the current timestamp in DB2 using:
Code:
CURRENT TIMESTAMP
or
Code:
CURRENT_TIMESTAMP
The latter is what the SQL standard defines, too.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 09-06-07, 05:29
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
sorry I attached the wrong link... The message is little bit down in document. So right link is:
http://troels.arvin.dk/db/rdbms/#fun...LOCALTIMESTAMP

At Standard section:
Code:
If the DBMS supports the non-core time zone features (feature ID F411),
 then it must also provide the functions CURRENT_TIMESTAMP and
 CURRENT_TIMESTAMP(precision) which return a value of type TIMESTAMP
WITH TIME ZONE. If it doesn't support time zones, then the DBMS
 must not provide a CURRENT_TIMESTAMP function.
So DB2 brakes this rule: "then the DBMS must not provide a CURRENT_TIMESTAMP function."

At DB2 section:
Code:
the availability of CURRENT_TIMESTAMP could be said
to be against the standard—at least confusing.
Regards,
Grofaty

Last edited by grofaty; 09-06-07 at 05:32.
Reply With Quote
  #7 (permalink)  
Old 09-07-07, 10:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Could you please provide me with a reference (number of the subclause) where this is written in the standard? I'm just curious because - usually - the standard does not mandate that a conforming implementation does not provide some functionality if it does not support a certain feature.
__________________
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