Date of Birth

H

Heather

I have a list of dates of birth and I need to sort them by month and day only
and not year. I know that there is a way to do this but can't remember the
fx. Can someone provide me with it.
Thanks in advance,
Heather
 
W

Wayne-I-M

Hi Heather

Add 2 columns to a query

DateOfBirthDAY:DatePart("d",[TableName]![DateofBirth])
and
DateOfBirthMONTH:DatePart("m",[TableName]![DateofBirth])

and sort by these - something like this

SELECT DatePart("d",[TableName]![DateofBirth]) AS BirthDayDAY,
DatePart("M",[TableName]![DateofBirth]) AS BirthDayMONTH
FROM TableName
ORDER BY DatePart("d",[TableName]![DateofBirth]),
DatePart("M",[TableName]![DateofBirth]);
 
D

Duane Hookom

Whoa... Since this is a report, you can't rely on the sorting in the report's
recordsource query. All sorting in a report should be performed in the
Sorting and Grouping dialog in the report design view. You can enter the
expressions:
=Month([DateOfBirth])
=Day([DateOfBirth])
Or just
=DateFormat([DateOfBirth],"MMDD")
I generally prefer the two expressions since it is easier to group on the
month.
--
Duane Hookom
Microsoft Access MVP


Steve said:
Wayne,

The US expression for dates is MMDDYY. Presumably Heather is US so the Order
By clause in your query needs to be:

ORDER BY
DatePart("M",[TableName]![DateofBirth]),DatePart("d",[TableName]![DateofBirth]);

Steve
(e-mail address removed)



Wayne-I-M said:
Hi Heather

Add 2 columns to a query

DateOfBirthDAY:DatePart("d",[TableName]![DateofBirth])
and
DateOfBirthMONTH:DatePart("m",[TableName]![DateofBirth])

and sort by these - something like this

SELECT DatePart("d",[TableName]![DateofBirth]) AS BirthDayDAY,
DatePart("M",[TableName]![DateofBirth]) AS BirthDayMONTH
FROM TableName
ORDER BY DatePart("d",[TableName]![DateofBirth]),
DatePart("M",[TableName]![DateofBirth]);



--
Wayne
Trentino, Italia.



Heather said:
I have a list of dates of birth and I need to sort them by month and day
only
and not year. I know that there is a way to do this but can't remember
the
fx. Can someone provide me with it.
Thanks in advance,
Heather
 
D

Duane Hookom

Sorry about that. I thought this was a report question. If you want to
display the results in a report, ignore the sorting in the query.
--
Duane Hookom
Microsoft Access MVP


Duane Hookom said:
Whoa... Since this is a report, you can't rely on the sorting in the report's
recordsource query. All sorting in a report should be performed in the
Sorting and Grouping dialog in the report design view. You can enter the
expressions:
=Month([DateOfBirth])
=Day([DateOfBirth])
Or just
=DateFormat([DateOfBirth],"MMDD")
I generally prefer the two expressions since it is easier to group on the
month.
--
Duane Hookom
Microsoft Access MVP


Steve said:
Wayne,

The US expression for dates is MMDDYY. Presumably Heather is US so the Order
By clause in your query needs to be:

ORDER BY
DatePart("M",[TableName]![DateofBirth]),DatePart("d",[TableName]![DateofBirth]);

Steve
(e-mail address removed)



Wayne-I-M said:
Hi Heather

Add 2 columns to a query

DateOfBirthDAY:DatePart("d",[TableName]![DateofBirth])
and
DateOfBirthMONTH:DatePart("m",[TableName]![DateofBirth])

and sort by these - something like this

SELECT DatePart("d",[TableName]![DateofBirth]) AS BirthDayDAY,
DatePart("M",[TableName]![DateofBirth]) AS BirthDayMONTH
FROM TableName
ORDER BY DatePart("d",[TableName]![DateofBirth]),
DatePart("M",[TableName]![DateofBirth]);



--
Wayne
Trentino, Italia.



:

I have a list of dates of birth and I need to sort them by month and day
only
and not year. I know that there is a way to do this but can't remember
the
fx. Can someone provide me with it.
Thanks in advance,
Heather
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top