Solved

employee anniv date with text field type

Posted on 2016-11-14
9
48 Views
Last Modified: 2016-11-16
I have a query i'm trying to correct:
In my table...someone set up the "datehired" as text.

In my sql i'm trying to select employees within a given months range...september  to  december...i.e.
etc...

combo25 is the start month "september  to         combo27 "december" end month

The date hired field looks like  

02/01/2010
05/06/1995

Problem:
qry is pulling back all records..


I changed the  field type to date/time   "Short date"
but it did not help ?



SELECT [First Name] & " " & [Last Name] AS [Full Name], [Employees Information2]![Date Hired] AS [Date Hired], [Employees Information2].[Report to] AS [Reports To], [Employees Information2].Title, Year(Date())-Year([Employees Information2]![Date Hired]) AS [Years of Service]
FROM [Employees Information2]
WHERE (((Month([Employees Information2]![Date Hired])) Between [forms]![Maintenance]![Combo25] And [forms]![Maintenance]![Combo27]))
ORDER BY Month([Employees Information2]![Date Hired]), Year(Date())-Year([Employees Information2]![Date Hired]) DESC;

Open in new window



Thanks
fordraiders
0
Comment
Question by:fordraiders
[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
  • 4
  • 4
9 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 41886966
what is the row source of your combo boxes?
add a column to represent the Months in Numeric values
1 January
2 February
..

12 December

and set the Bound Column of the combo to 1

your criteria
Month([Employees Information2]![Date Hired])  - will return a numeric value  1 to 12
0
 
LVL 3

Author Comment

by:fordraiders
ID: 41886983
i have in a table
field1       field 2
1               january
2               february

etc...

the combbox is bound to column 1
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41886991
then your query should work...

can  you upload a copy of the db?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 3

Author Comment

by:fordraiders
ID: 41887026
so if i choose the  9 - september   to 12 - december...I only want to pull months from 9 to 12..the year and day will not come into play...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41887074
yes that is correct, all records with Month _  sept to dec will be return regardless of the year.

if you want to consider the Year and day the criteria will be different.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 41887129
Between [forms]![Maintenance]![Combo25] +1 And [forms]![Maintenance]![Combo27]+1

I had to do this in order to get it to work ?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41887152
are you saying this

Between [forms]![Maintenance]![Combo25] +1 And [forms]![Maintenance]![Combo27]+1

made it work?
0
 
LVL 36

Accepted Solution

by:
PatHartman earned 250 total points
ID: 41888287
Your best option is to bite the bullet and change the date field to BE a real datetime data type.  Then you won't have any difficulty working with it as a date.

No "between" logic will work correctly when comparing two dates stored as text in mm/dd/yyyy format.  Since "01/30/2016" will ALWAYS be less than "02/01/2001"
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41889906
I changed the bound column. and kept field type as date/time. worked
0

Featured Post

Technology Partners: 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

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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 …

735 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