Get Number of the days – Oracle Query

1. How to get a number of the days in a month,

for xample : we want to know the number of days in Fuary 2012. SQL statement in oracle can be :

select TO_NUMBER(TO_CHAR(last_day(TO_DATE(’01-02-2012′,’DD-MM-YYYY’)),’DD’)) DY FROM DUAL

Result is 29

2. How to gets number of the days between range of two date,

for example you want to get numbers of the day between 17-07-2012 and ’30-06-2012

select (to_date(’17-07-2012′,’DD-MM-YYYY’) – to_date(’30-06-2012′,’DD-MM-YYYY’))+1 n from dual;

Result is 18


About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on July 16, 2012, in Oracle and tagged , , . Bookmark the permalink. 1 Comment.

  1. Query Oracle , it’s all about date format, date calculation, and other date

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: