Re: sort per date, today on top

Tech-Archive recommends: Fix windows errors by optimizing your registry



=?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

.



Relevant Pages

  • Re: small program
    ... are not logic and maths. ... a native English speaker is ... or "If the outside temperature is below 20 degrees ...", ... no risk of accidentally assigning instead of comparing; ...
    (comp.lang.c)
  • Re: Is there an XML editor for Eclipse?
    ... Does it offer a button to 'validate' the document? ... I bet you are comparing the 3 extra buttons added by NB6 when an XML ... You open an XML file, right click on it and select "View Data ...
    (comp.lang.java.programmer)