A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Stuck on a date issue



 
 
Thread Tools Display Modes
  #1  
Old July 8th, 2008, 06:39 PM posted to microsoft.public.access.queries
Sue
external usenet poster
 
Posts: 722
Default Stuck on a date issue

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!
  #2  
Old July 8th, 2008, 06:47 PM posted to microsoft.public.access.queries
Michel Walsh
external usenet poster
 
Posts: 2,404
Default Stuck on a date issue

SELECT *
FROM somewhere
ORDER BY Month(yourDateField), Day(yourDateField)




Vanderghast, Access MVP


"Sue" wrote in message
...
Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding
the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!



  #3  
Old July 8th, 2008, 06:53 PM posted to microsoft.public.access.queries
Ryan
external usenet poster
 
Posts: 551
Default Stuck on a date issue

Add another field in your query.
DayMonthSort:Format$([YourDateField],"dd")
This will only show the day and then you can change the sort to asending.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!

  #4  
Old July 8th, 2008, 07:00 PM posted to microsoft.public.access.queries
Sue
external usenet poster
 
Posts: 722
Default Stuck on a date issue

Will this include the month? If so, I truly don't understand!
--
Thanks for your time!


"Ryan" wrote:

Add another field in your query.
DayMonthSort:Format$([YourDateField],"dd")
This will only show the day and then you can change the sort to asending.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!

  #5  
Old July 8th, 2008, 07:07 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default Stuck on a date issue

Sue wrote:
Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort
disregarding the year... in other words, the following fields would
sort this way:

03/07/1972
04/01/1930
07/12/1947


Quick terminology nitpick (sorry): fields (columns) go across, records
(rows) go down. So I am assuming you meant that you want data in these rows:
07/12/1947
03/07/1972
04/01/1930
to be ordered like this:
03/07/1972
04/01/1930
07/12/1947


Any way I slice & dice it, I can't figure this 'un out.


Is this a Text field or a Date/Time field? If the latter, the Format is
irrelevant: Date/Time values are stored without format. The Format property
is only applied when the values are displayed.

Assuming you have a Date/Time field, switch your query to SQL View (using
the View menu, or the toolbar button, or the right-click menu) and add the
ORDER BY clause like this:

select ...
from ...
where ...
ORDER BY Month([yourfield]),Day([yourfield])

If it's a Text field, then you need to initially convert to date/time:

ORDER BY Month(CDate([yourfield])),Day(CDate([yourfield]))



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #6  
Old July 8th, 2008, 07:09 PM posted to microsoft.public.access.queries
Michel Walsh
external usenet poster
 
Posts: 2,404
Default Stuck on a date issue

Well, if you use the grid, add one computed expression:

Month( yourDateField)

and add another computed expression:

Day( yourDateField)


then spedify you want the ordering be done (ascending) under these two
expression. You are not obliged to SHOW these computed expressions.



Vanderghast, Access MVP



"Sue" wrote in message
...
Will this include the month? If so, I truly don't understand!
--
Thanks for your time!


"Ryan" wrote:

Add another field in your query.
DayMonthSort:Format$([YourDateField],"dd")
This will only show the day and then you can change the sort to asending.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding
the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!



  #7  
Old July 8th, 2008, 07:17 PM posted to microsoft.public.access.queries
Sue
external usenet poster
 
Posts: 722
Default Stuck on a date issue

You steered me right - I just added mm/ to the "dd"
--
Thanks for your time!


"Ryan" wrote:

Add another field in your query.
DayMonthSort:Format$([YourDateField],"dd")
This will only show the day and then you can change the sort to asending.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!

  #8  
Old July 8th, 2008, 07:17 PM posted to microsoft.public.access.queries
Ryan
external usenet poster
 
Posts: 551
Default Stuck on a date issue

You can add the month, but I was suggesting that you not show that field and
just use it to sort the data.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Will this include the month? If so, I truly don't understand!
--
Thanks for your time!


"Ryan" wrote:

Add another field in your query.
DayMonthSort:Format$([YourDateField],"dd")
This will only show the day and then you can change the sort to asending.
--
Please remember to mark this as answered if this solves your problem.


"Sue" wrote:

Hi all, and thanks in advance.

I have dates entered in mm/dd/yyyy format but want to sort disregarding the
year... in other words, the following fields would sort this way:

03/07/1972
04/01/1930
07/12/1947

Any way I slice & dice it, I can't figure this 'un out.

--
Thanks for your time!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.