Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get last 30 days of records

Status
Not open for further replies.

tracy1234

MIS
Apr 2, 2003
108
US
I'm trying to pull the past x days of transactions via a select query that's using a pass through.

My select looks like this:

SELECT [pt get fulfillment invoices].*
FROM [pt get fulfillment invoices]
WHERE ((now())-[pt get fulfillment invoices].[TRX_DATE]) >=[Past ? Days];

Past ? Days is for the user to input a number.

I've used something similar before directly in the passthrough using round(sysdate)instead of now() but I can't seem to use "sysdate" in the select query and I can't get the passthrough to directly accept a user input.

-Tracy
 
Hi

Why not build the actual value:

assuming user entered value is in xDays,

strSQL = "SELECT [pt get fulfillment invoices].*
FROM [pt get fulfillment invoices]
WHERE [TRX_DATE]) <= #&quot; & DateAdd(&quot;d&quot;,-xDays,DAte()) & &quot;#;&quot;




Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Sorry Ken, you've lost me. Even without the extra &quot; at the end of the statement, I get a syntax error in the select statement and an odbc failure if I use it directly in the passthrough. Where exactly am I supposed to be using this?

How does it prompt the user for xdays?

-Tracy
 
As it turns out the select query does work as is if only I had remembered to take out the hard coded date range in my pass-through query. Duh!

-Tracy
 
Hi There,

Create a form for the user to enter the value of days in a textbox.

Then in your SQL make it >= Forms![FromName]![textboxname}

See if that works...

Krystal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top