Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parameter Query with wildcard

Posted on 2013-05-25
10
Medium Priority
?
382 Views
Last Modified: 2013-05-25
Hi,
I have this parameter query Like "*" & [Date] & "*"

I would like to be able to add a date range. Unfortunately I can't use the standard Between - And parameter because my data is from a linked table that has the date and time in the field.

Thanks,
Ward
0
Comment
Question by:draw58
10 Comments
 
LVL 35

Expert Comment

by:Norie
ID: 39196596
Ward

What dates are you actually looking for?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39196600
If you need to do a Date range comparison (user inputs the range), without the time portion, then switch to SQL View and use this for the WHERE clause of your query:

WHERE DatePart([YourDateTimeFIeld]) BETWEEN [Start Date] AND [End Date]
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 39196651
personally, i would recommend using

"where [datefield] >= #" & [from date] & "# and [date field] < #" & dateadd("d", 1, [thru date]) & "#"
0
Industry Leaders: 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!

 

Author Comment

by:draw58
ID: 39196684
This is my SQL. I am getting an error "Wrong number of arguments used with function in query expression.

SELECT [Sales History].TKT_NO, [Sales History].TKT_DT, [Sales History].SLS_REP, [Sales History].STR_ID, [Sales History].ITEM_NO, [Sales History].DESCR, [Sales History].CATEG_COD, [Sales History].QTY_SOLD, [Sales History].EXT_COST, [Sales History].EXT_PRC, [Sales History].PRC_OVRD_REAS, [Sales History].NAM, [Sales History].CUST_NO, [Sales History].EMAIL_ADRS_1, [Sales History].NAM1, [Sales History].ITEM_VEND_NO, [Sales History].SUBCAT_COD, [Sales History].PRC_1, [EXT_PRC]-[EXT_COST] AS PROFIT, ([EXT_PRC]-[EXT_COST])/[EXT_PRC] AS [Profit Percent]
FROM [Sales History]
WHERE DatePart([TKT_DT]) BETWEEN [Start Date] AND [End Date]
0
 
LVL 77

Expert Comment

by:peter57r
ID: 39196689
The function should be DateValue() not DatePart()
0
 

Author Comment

by:draw58
ID: 39196734
I get "data type mismatch" when i switch to DateValue
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39196740
Do you have nulls in your data?

Try

DateValue(nz(yourdatefield, #1/1/1900#))
0
 

Author Comment

by:draw58
ID: 39197123
Nope, I don't have any nulls. Where do I put DateValue(nz(yourdatefield, #1/1/1900#)) ?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39197137
Try this:


SELECT [Sales History].TKT_NO, [Sales History].TKT_DT, [Sales History].SLS_REP, [Sales History].STR_ID, [Sales History].ITEM_NO, [Sales History].DESCR, [Sales History].CATEG_COD, [Sales History].QTY_SOLD, [Sales History].EXT_COST, [Sales History].EXT_PRC, [Sales History].PRC_OVRD_REAS, [Sales History].NAM, [Sales History].CUST_NO, [Sales History].EMAIL_ADRS_1, [Sales History].NAM1, [Sales History].ITEM_VEND_NO, [Sales History].SUBCAT_COD, [Sales History].PRC_1, [EXT_PRC]-[EXT_COST] AS PROFIT, ([EXT_PRC]-[EXT_COST])/[EXT_PRC] AS [Profit Percent]
FROM [Sales History]
WHERE DateValue(nz([TKT_DT], #1/1/1900#)) BETWEEN CDate([Start Date]) AND CDate([End Date])

Open in new window

0
 

Author Closing Comment

by:draw58
ID: 39197249
Perfect! Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

926 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