Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2009
    Posts
    27

    Question Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Code:
    VALUES CURRENT TIMESTAMP - SECONDS(CURRENT TIMESTAMP) SECONDS
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

  5. #5
    Join Date
    Dec 2008
    Posts
    59

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    once again, hkp819, i feel compelled to ask you "wtf???"
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •