Re: sort per date, today on top
- From: Tim Ferguson <FergusonTG@xxxxxxxxxxxx>
- Date: Mon, 08 May 2006 10:22:16 -0700
=?Utf-8?B?VWxyaWNoMTk0Nw==?= <Ulrich1947@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in news:B2DB8E98-7AD0-4D83-9FE3-7E7D71F0E5F6@xxxxxxxxxxxxx:
and thanks for reminding me, that a month and a day is not a date. I
probably should have formatted the size of the field not as a date -
now I know.
The best way to model a non-date is far from obvious. The other common scenario is
Month+Year but no Day.
With your combination you could try:
two integer fields: bit fiddly to validate, ugly but reasonable user interface,
very easy to do maths with (using DateSerial() function)
one integer field using a Julian Date - easiest to validate, takes some work for
any kind of user friendliness at all; date maths is again extremely simple
one string field formatted something like "mm/dd" -- much more fiddly to
validate, but obvious and intuitive for users without any programming work, sorting
and comparing is easy but any date maths starts to get fraught.
The best solution depends on how you plan to use the things. For example, you could
benchmark the three methods on the type of comparison you mention in your post
(by the way I have not tested any of these, but you should get the picture!):-
ORDER BY DateSerial(
IIf(DateSerial(Year(Date(),MonthNum, DayNum) > Date(),
Year(Date()),
Year(Date())+1),
MonthNum,
DayNum
) ASC;
ORDER BY JulianDate +
IIf(JulianDate < DatePart("y", Date()), 0, 365)
ORDER BY DateSerial(
IIf(DateSerial(
Year(Date(),
CInt(Mid(DateText,1,2)),
CInt(Mid(DateText,3,2))
) > Date(),
Year(Date()),
Year(Date())+1),
CInt(Mid(DateText,1,2)),
CInt(Mid(DateText,3,2))
);
Hope that helps
Tim F
.
- References:
- Re: sort per date, today on top
- From: Tim Ferguson
- Re: sort per date, today on top
- Prev by Date: Re: write conflict error
- Next by Date: Re: making babies???????????
- Previous by thread: Re: sort per date, today on top
- Next by thread: Re: How to avoid user to enter the Visual Basic Windows?
- Index(es):
Relevant Pages
|