Solved

employee anniv date with text field type

Posted on 2016-11-14
9
23 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
  • 4
  • 4
9 Comments
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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 119

Expert Comment

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

can  you upload a copy of the db?
0
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 41887152
are you saying this

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

made it work?
0
 
LVL 34

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now