Solved

Need help with query for Pervasive

Posted on 2014-11-26
2
122 Views
Last Modified: 2014-12-30
I have a query that I want to use for extracting data form a Pervasive database and then insert to a table.

This is the first part of the query which works in PostgreSQL

SELECT d.whse, d.part_no, EXTRACT(YEAR FROM d.invoice_date), EXTRACT(MONTH FROM d.invoice_date)
FROM sales_history_items AS d

Open in new window


In Pervasive the invoice_date is a string like so 20141128

Can someone help me with this? Once I got this working I will post the whole query is I need more help.
0
Comment
Question by:Gerhardpet
2 Comments
 
LVL 18

Expert Comment

by:mirtheil
ID: 40467071
I'm guessing the problem with Pervasive is the EXTRACT part.  If that's not the case, post the version of Pervasive and the error you are seeing.  
If it is the EXTRACT, the Pervasive syntax for EXTRACT (in v10 and v11, at least) is:
EXTRACT (extract_field, extract_source)

Open in new window

So your query would be :
SELECT d.whse, d.part_no, EXTRACT(YEAR, d.invoice_date), EXTRACT(MONTH, d.invoice_date)
FROM sales_history_items AS d

Open in new window

0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 40467113
If InvoiceDate is a String field, then you cannot use Extract.  Use Substring instead!
SELECT d.whse, d.part_no, LEFT(d.invoice_date,4), RIGHT(LEFT(d.invoice_date,6),4)
FROM sales_history_items AS d

Open in new window

MID might also work, but I sometimes have issues with that.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question