ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

In SQL Query: How can you get the dates between two provided dates?

The provided dates from1/3/2014 to4/3/2014 the result should be like this:1/3/2014-2/3/2014-3/3/2014-4/3/2014

user-image
تم إضافة السؤال من قبل Qussay Nasser Eddin , Training Engineer , Direct Aid Organization
تاريخ النشر: 2014/08/10

select to_date('01/03/2014', 'DD/MM/YYYY') + rownum -1 dt

from dual

connect by level <= to_date('04/03/2014', 'DD/MM/YYYY') - to_date('01/03/2014', 'DD/MM/YYYY') +1;

With parameters

select to_date(:from_date,'DD/MM/YYYY') + rownum -1 dt

from dual

connect by level <= to_date(:to_date,'DD/MM/YYYY') - to_date(:from_date,'DD/MM/YYYY') +1;

Muktar SayedSaleh
من قبل Muktar SayedSaleh , Software Engineering Manager , AIRASIA

using

 

where datefield between @startDate and @endDate ...

 

 

Akram Wahid
من قبل Akram Wahid , Senior Web Developer , Jaber Bin Ali Group

DECLARE

@MinDate DATE = '',

@MaxDate DATE = '';

 

SELECT  Date

FROM    dbo.Calendar

WHERE   Date >= @MinDate

AND     Date < @MaxDate;

Qussay Nasser Eddin
من قبل Qussay Nasser Eddin , Training Engineer , Direct Aid Organization

Select

 

to_date('01/03/2014','dd/mm/rrrr')+rnum-

1

from(selectrownum

rnum

from

all_objects

whererownum<=to_date('04/03/2014','dd/mm/rrrr')-

--END Date

to_date('01/03/2014','dd/mm/rrrr')+1)

--Start Date

Deepika Kumari
من قبل Deepika Kumari , Software Engineer , Wipro Technologies

Select Date, Totalsalary from Salarystack where EmployeeId =1 and Date >='2014/02/12' and Date <='2014/02/14'

Venugopalan Poovakundil
من قبل Venugopalan Poovakundil , Senior Systems Analyst , RCMC - Yanbu

select 

   A, 

   substr(SYS_CONNECT_BY_PATH(DATE, ','),2) DATE_list 

from 

   ( 

   select 

     DATE, 

     A, 

     count(*) OVER ( partition by A ) cnt, 

     ROW_NUMBER () OVER ( partition by A order by DATE) seq 

   from 

     TABLE 

   where 

     A is not null) 

where 

   seq=cnt 

start with 

   seq=1 

connect by prior 

   seq+1=seq 

and prior 

   A=A; 

-----------

ALTERNATE OPTIONS

 

 

 PIVOT TABLE FUNCTION

 OR 

 CASE FUNCTIONS 

 

CAN BE USED.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟