SQL STATEMENT WORKS WITH ADS BUT NOT PG

Use this forum for questions and answers regarding PostGreSQL and the PGDBE.
Post Reply
Message
Author
User avatar
unixkd
Posts: 597
Joined: Thu Feb 11, 2010 1:39 pm

SQL STATEMENT WORKS WITH ADS BUT NOT PG

#1 Post 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

User avatar
Tom
Posts: 1253
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

#2 Post by Tom »

Hi, Joe.

Maybe you try the DATE_PART function: https://neon.tech/postgresql/postgresql ... -date_part
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
unixkd
Posts: 597
Joined: Thu Feb 11, 2010 1:39 pm

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

#3 Post by unixkd »

Hi Tom

The link is not accessible

Thanks

Joe

User avatar
Tom
Posts: 1253
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

#4 Post 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".
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
unixkd
Posts: 597
Joined: Thu Feb 11, 2010 1:39 pm

Re: SQL STATEMENT WORKS WITH ADS BUT NOT PG

#5 Post by unixkd »

Hi Tom

Got it. Perfect !!!

Many thanks

Joe

Post Reply