jovany
jovany

Reputation: 227

Extract number from the date in pl sql

Does anyone know if it is possible to take the date from a random date in pl sql.

example.

SELECT SYSDATE FROM DUAL

and here the output would be say : 26-10-2010 13:30:34

Now I want to have just the date as a number. In this case that would be 26.

Or is there some sort of function like IsNum that can recognize it for me. So I can just take 26 and leave the rest out.

Upvotes: 3

Views: 3478

Answers (5)

drap
drap

Reputation: 11

select count(*) from 
     (select sysdate+rownum dates from  dual connect by rownum < (sysdate+15)-(sysdate))  
   where to_char(dates,'D') <> '1' and to_char(dates,'D') <> '7'

Upvotes: 1

andr
andr

Reputation: 1646

All format models are described in the official SQL Reference, take a look in case you need something else

Upvotes: 3

Alex Rashkov
Alex Rashkov

Reputation: 10015

You can use

to_char(SYSDATE, 'DD')

More you can read here: LINK

Upvotes: 4

BoltClock
BoltClock

Reputation: 723448

You can also use EXTRACT(), like so:

SELECT EXTRACT(DAY FROM SYSDATE) AS DAY FROM DUAL;

Upvotes: 10

Tony Andrews
Tony Andrews

Reputation: 132570

select to_char(sysdate,'DD') as day from dual

Upvotes: 5

Related Questions