Kalyan
Kalyan

Reputation: 378

How to find the issue with dual in oracle?

I am using Oracle SQL developer. I am using the following query to get the current time stamp.

select to_char(CURRENT_TIMESTAMP,'DDMMYYYY/HHMMSS') from dual;

In this, minutes is constantly set to 10. But when we don't use to_char, it is working fine. How to find what went wrong? Is there any method to correct this?

Upvotes: 0

Views: 63

Answers (2)

Boneist
Boneist

Reputation: 23578

select to_char(CURRENT_TIMESTAMP,'DDMMYYYY/HHMMSS') from dual;

The issue is with the HHMMSS - MM is used to represent the month number. MI is what is used to represent minutes.

So what you're really after is:

select to_char(CURRENT_TIMESTAMP,'DDMMYYYY/HHMISS') from dual;

Upvotes: 0

meskobalazs
meskobalazs

Reputation: 16041

You should use MI in HHMMSS instead of MM. MI stands for minutes, MM is for months, and currently it is October, hence the 10.

You can find the available formatting options at Oracle's site.

Upvotes: 4

Related Questions