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 > Convert Statement in db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-02-09, 07:50
vivek.vivek vivek.vivek is offline
Registered User
 
Join Date: Jan 2009
Posts: 27
Question Convert Statement in db2

Plese help me to convert this to db2.
The statement is in SQL.

select convert(varchar(50),getdate(),1) +' '+cast(convert(varchar(50),getdate(),8) as varchar(5)) as d1

Thanks in Advance,
Vivek Kumar
Reply With Quote
  #2 (permalink)  
Old 02-02-09, 08:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the effect of this monstrously inefficient SQL Server (not SQL) expression is to truncate the current datetime to the nearest earlier whole minute

so 2009-02-02 09:37:21 becomes 2009-02-02 09:37:00

does that help?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-02-09, 09:35
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Code:
VALUES CURRENT TIMESTAMP - SECONDS(CURRENT TIMESTAMP) SECONDS
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 02-02-09, 09:49
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Building on Knut's solution :

Code:
VALUES (CURRENT TIMESTAMP - SECOND(CURRENT TIMESTAMP) SECONDS - MICROSECOND(CURRENT TIMESTAMP) MICROSECONDS )
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 02-03-09, 00:22
hkp819 hkp819 is offline
Registered User
 
Join Date: Dec 2008
Posts: 59
__________________
New York Web design
Website design

Reply With Quote
  #6 (permalink)  
Old 02-03-09, 00:55
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
once again, hkp819, i feel compelled to ask you "wtf???"
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 02-03-09, 07:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I think this is cool... a website with a badly formatted SQL statement and no one has any idea how it relates to the current thread. :-)
__________________
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