Sort
Home
Up

SORT BY DATE

You can sort a field of dates using the Quick Sort feature, and you'll get a chronological list. That's not the only way to sort dates, though. If you wrap your date field in a DatePart() function, the many possibilities may surprise you. For instance, the expression

=DatePart("m",[date])

in a query, where date represents your date field, returns a column of integers between 1 and 12, each representing the corresponding date's month component. To sort the records by month, you'd simply select the appropriate sort order in the Sort field.

You could use this function with any of the following codes:

yyyy returns the four-digit year
q returns the quarter (1 to 4)
m returns the month (1 to 12)
y returns the two-digit year
d returns the day as a digit (1 to 31)
w returns the day of the week as a digit (1 to 7)
ww returns the week of the year ( 1 to 52)
h returns the hour in military time
n returns the minute
s returns the second


last updated: Monday, 24. May 1999 09:47:09 -0500