By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,226 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,226 IT Pros & Developers. It's quick & easy.

Seek DB2 translation of Oracle statement with date stuff

P: n/a
Might some kind soul take on this Oracle statement and
translate it into DB2? Yes ... I know the equivalent of SYSDATE
is CURRENT TIMESTAMP, and that DUAL is SYSIBM.SYSDUMMY1.
But I'm puzzled by the 'Q' (Quarter), and NEXT_DAY
translations. Thanks.

SELECT
TO_CHAR(SYSDATE, 'Q') Q,
TO_CHAR(SYSDATE, 'MM') MON,
TO_CHAR(NEXT_DAY(SYSDATE,'SUNDAY' ),'MM/DD/YYYY') WEEKEND,
TO_CHAR(SYSDATE,'YYYY') YEAR
from DUAL

SQL> /

Q MO WEEKEND YEAR
- -- ---------- ----
2 06 06/12/2005 2005
Um.. If I need a custom Quarter function and you have one
that would be nice. Again... Thanks.

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
------------------------------ Commands Entered
------------------------------
SELECT
QUARTER(CURRENT DATE) Q,
MONTH(CURRENT DATE) MON,
CHAR(NEXT_DAY(CURRENT DATE,'Sunday' ),USA) WEEKEND,
YEAR(CURRENT DATE) "YEAR"
from SYSIBM.SYSDUMMY1!
------------------------------------------------------------------------------

Q MON WEEKEND YEAR
----------- ----------- ---------- -----------
2 6 06/12/2005 2005

1 record(s) selected.

NEXT_DAYS is a sample UDF which is included in "Sample UDFs for
Migration".
http://www-106.ibm.com/developerwork...dfs/index.html

"DB2 Basics: Fun with Dates and Times" will be also usefull.
http://www-128.ibm.com/developerwork.../0211yip3.html

Nov 12 '05 #2

P: n/a
Thanks.

The NEXT_DAYS UDF is especially helpful.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.