Buy Support
Incidents |
If you can't find your answer
in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us
private or confidential information: |
Click Here
|
If you can't
login and post questions or you are having trouble viewing forum posts:
Click Here
|
Callback
Support |
If you live in USA, UK, Canada, Australia or New
Zealand, you can leave us details on your question and request us to call you back and discuss
them with you personally (charges apply). |
Click Here
|
Buy Support
Incidents |
If you can't find your answer
in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us
private or confidential information: |
Click Here
|
|
How do I query Invoice lines where TxnDate=Yesterday using CURDATE? |
Author |
Message |
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-04-03 08:09:13 |
I am using Excel to pull info from the InvoiceLine QB table. This triggers the 'Microsoft Query' program which looks similar to an access design grid.
I am trying to understand how to limit the TxnDate from the InvoiceLine table to yesterday.
I tried the following in the SQL dialog box and it does not work, it says "Expected lexical element not found:]"
SELECT InvoiceLine.TxnDate, InvoiceLine.InvoiceLineItemRefListID, InvoiceLine.InvoiceLineItemRefFullName, InvoiceLine.InvoiceLineQuantity FROM InvoiceLine InvoiceLine WHERE (InvoiceLine.TxnDate>{CURDATE()-1}) ORDER BY InvoiceLine.InvoiceLineItemRefListID
Can someone show me the proper way to use this function, or alternatively how to limit the query always to yesterday without explicitly going in and typing the date every day?
Thankyou
|
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-04-03 08:29:47 |
You nearly had it. Try:
SELECT InvoiceLine.TxnDate, InvoiceLine.InvoiceLineItemRefListID, InvoiceLine.InvoiceLineItemRefFullName, InvoiceLine.InvoiceLineQuantity, {fn CURDATE()} as Today, ({fn CURDATE()}-1) as Yesterday FROM InvoiceLine InvoiceLine WHERE (InvoiceLine.TxnDate > {fn CURDATE()}-1) and InvoiceLineItemRefListID is not null ORDER BY InvoiceLine.InvoiceLineItemRefListID
|
|
|
|
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-04-03 09:32:08 |
Thanks for your assistance.
I tried it like you said (typed it first, then pasted it instead), but I am coming up with the headers but no data. I verified that I have a transaction for yesterday by creating a separate nonfiltered query.
Also, recall I am using the "Microsoft Query' program that pops up when I invoke Data\Import External Data\New Database Query from within microsoft excel. the microsoft query program shouldn't care should it? Or does it need something installed that I am missing?
Again, thank you for your help
|
|
|
|
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-04-03 09:34:35 |
Oh, and btw, the VB demo form you posted is showing TxnDates that are not yesterday, its showing everything. Not sure what that means either.
Thanks |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-04-03 09:42:53 |
For yesterday's invoices only, I would use TxnDate equals, and not TxnDate greater than yesterday:
SELECT InvoiceLine.TxnDate, InvoiceLine.InvoiceLineItemRefListID, InvoiceLine.InvoiceLineItemRefFullName, InvoiceLine.InvoiceLineQuantity, {fn CURDATE()} as Today, ({fn CURDATE()}-1) as Yesterday FROM InvoiceLine InvoiceLine WHERE (InvoiceLine.TxnDate = {fn CURDATE()}-1) and InvoiceLineItemRefListID is not null ORDER BY InvoiceLine.InvoiceLineItemRefListID
As far as the Microsoft Query is concerned, use:
SELECT InvoiceLine.TxnDate, InvoiceLine.InvoiceLineItemRefListID, InvoiceLine.InvoiceLineItemRefFullName, InvoiceLine.InvoiceLineQuantity FROM InvoiceLine InvoiceLine WHERE (InvoiceLine.TxnDate>{CURDATE()}-1) ORDER BY InvoiceLine.InvoiceLineItemRefListID |
|
|
|
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-04-03 10:03:04 |
Disregard the last two posts, I got it to work. Not sure what I was doing wrong, but when I noticed your txndates I thought that they were for last Nov. and Dec. When I realized they are for next Nov. and Dec. I went into vb demo, built it up in pieces and finally succeeded. Not sure what I was doing wrong but it works now, just as you said! Thankyou!
Question: I have been saving each of the queries I have created to a different filename, but I think this is creating multiple applications permissions entries in quickbooks. They are difficult to discern because all it tells me is 'FLEXquarters QODBC' (there are 5 of these in there now). Should I be doing it this way? or should I save all my queries (all used by this specific front end excel app) under one file name?
Thankyou |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-04-03 10:47:29 |
The muliple 'FLEXquarters QODBC' connections shown in Integrated Application is for each type of application you have used. It's normal to have three or more listed, like one for QODBC itself, MS Excel, MS Query etc. |
|
|
|
TomW |
|
Group | : Members |
Posts | : 24 |
Joined | : 2007-04-03 |
|
Profile |
|
Posted : 2007-04-04 05:19:32 |
I am not sure I understand you. With respect to the QODBC connections -- should I create one connection for Excel - and then save all my queries that I build to it?
What I have done is created 4 queries in excel and gave them 4 distinct names, should I have just saved all 4 queries under one name?
And if that is so I would create a different connection for Access, and save all those queries to it?
Thanks
|
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-04-04 08:24:13 |
|
|
|
|