Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Parameter Query with wildcard

Posted on 2013-05-25
10
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 34

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 48

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

705 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