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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Query 2

Status
Not open for further replies.

vonniago

MIS
Jun 18, 2002
13
0
0
US
I use a report writer that seems to have a limit to what I can do with dates. My criterion are: June Birthdays from January 1, 1942 to June 13, 2002 (or the day before doing the report. Then the patient list is whittled down to those who used our services during the last two years. The last visit date is very important also.

I have to do a birthday letter each month and took my document into excel and then into access to write a dob query that will sort my June Dates and present only June Dates. I want to Eliminate duplicates, (which is a big problem. I have been looking also for a way to create three columns, one for month, then day, then for year. That would solve all of my problems.
Thanks, Vonniago
 
you can use month(), day() and Year() function
or datepart() or even format() functions to accomplish waht you want

example: 1
select year(bithhdate)as byear,month(bithhdate) as bmonth,day(bithhdate)as bday from tablename where month(birthdate) = Month(date())

example: 2
select datepart(birthdate,"YYYY")as byear,datepart(birthdate,"m")as bmonth, datepart(birthdate,"d")as bday from yourtable.....

example: 3
select format(birthdate,"YYYY") as byear......


Hope that helps
 
So you have a table with patient name and dob right?

Well, if your table was called "Table1" your query would look like this:

SELECT DISTINCT Table1.Name, Table1.DOB FROM Table1 WHERE ((Month(Table1.DOB) = 6 ));

This will give you the query with only June dates and only 1 per person.

Now, for the three columned thingy:

SELECT DISTINCT Table1.Name, Month(Table1.DOB) As Month_, Day(Table1.DOB) As Day_, Year(Table1.DOB) As Year_ FROM Table1 WHERE ((Month(Table1.DOB) = 6 ));

This will give you:

Name Month Day Year
Steve 1 2 79
Joe 2 4 48 Kyle [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top