0

In MSSQL, I usually use below parameter like this:

declare @StartDate as date, @EndDate as date
set @StartDate  = '08/01/2015' set @EndDate = '08/15/2015'

----------- and use it here as my Date Range of Records:

Select * from Table_Name 
where DateRange between @StartDate and @EndDate 

How can I do this in PostgreSQL for generating reports/records?

Cœur
  • 37,241
  • 25
  • 195
  • 267
fLen
  • 468
  • 4
  • 13
  • 25

2 Answers2

0

Do like this After $BODY$

DECLARE startdate date;
DECLARE enddate date;

After begin

startdate ='2015-08-01';
Enddate ='2015-08-15';

retrun query 

select * from Table where daterange between startdate and endate
Ankit Agrawal
  • 2,426
  • 1
  • 13
  • 27
  • result: ERROR: syntax error at or near "date" LINE 3: DECLARE startdate date; ^ ********** Error ********** – fLen Dec 23 '15 at 00:36
  • @fLen its throwing error because you are executing this syntax directly.....use this syntax in your function then it will work fine. – Ankit Agrawal Dec 23 '15 at 04:48