Page 1 of 1

SQL STATEMENT WORKS WITH ADS BUT NOT PG

Posted: Sun Mar 16, 2025 7:28 pm
by unixkd
Hi All,

I have this statement that has worked well with ADS but failed in PG because PG has no month function:

SELECT Month(GLBook.DocDate) AS COL01, SUM(case when pc = 'D' then amount else 0 end) AS COL02, SUM(case when pc = 'C' then amount else 0 end) AS COL03, 0 AS COL04, 0 AS COL05, '' AS AcctPeriod, '' AS Site, '' AS Account FROM GLBook WHERE GLBook.DocDate >= ? AND GLBook.DocDate <= ? AND Account = ? AND Site = ? AND OrgCode = ? GROUP BY Month(GLBook.DocDate)

Your help will be highly appreciated

Thanks

Joe

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

Posted: Sun Mar 16, 2025 11:56 pm
by Tom
Hi, Joe.

Maybe you try the DATE_PART function: https://neon.tech/postgresql/postgresql ... -date_part

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

Posted: Mon Mar 17, 2025 4:53 am
by unixkd
Hi Tom

The link is not accessible

Thanks

Joe

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

Posted: Mon Mar 17, 2025 6:00 am
by Tom
Mmh. Maybe it works if you copy this into your browser address row: neon.tech/postgresql/postgresql-date-functions/postgresql-date_part

Or just search for "Date_Part" and "PostGreSQL".

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

Posted: Mon Mar 17, 2025 6:02 am
by unixkd
Hi Tom

Got it. Perfect !!!

Many thanks

Joe