Brief introduction DB2 Common functions and Oracle comparisons

Source: Internet
Author: User
Tags current time db2

This paper introduces the comparison of DB2 common functions with Oracle in detail

1. Type conversion functions: Decimal, Double, Integer, Smallint,real,hex (ARG),

Date, Time,timestamp,char, varchar

Common examples:

--Convert to String type

Oracle:select To_char (15.5000) from dual;

Db2:select char (15.5000) from sysibm.sysdummy1

--Convert to date time

Oracle:select to_date (' 2008-01-01 ', ' YYYY-MM-DD ') from dual;

Db2:select date (' 2008-01-01 ') from sysibm.sysdummy1

2, Date: Year, quarter, month, week, day, hour, minute, second

DayOfYear (ARG): Returns the day value of ARG in the year

DayOfWeek (ARG): Returns the day value of ARG within a week

Days (ARG): Returns the integer representation of the date, from 0001-01-01.

Midnight_seconds (ARG): The number of seconds between midnight and Arg.

MonthName (ARG): Returns the name of the month for Arg.

Dayname (ARG): Returns the week of Arg.

Common examples:

--Returns the current system time

Oracle:select sysdate from dual;

Db2:select Current date from sysibm.sysdummy1

--Returns the next day of the current time (same as year)

Oracle:select sysdate,sysdate + interval ' 1 ' from dual;

Db2:select Current date + 1 day sysibm.sysdummy1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.