Access SQL Date Sort Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to get a set of dates to sort on an ASP page accessing an Access
DB. I want the dates due first at the top, but it is putting the nulls first
instead. I tried doing a replace of nulls with a larger date using this code
(IIF(ISNULL(p.due_date),#3/31/2050#,p.due_date) AS due_date) but it didn't
work. Any ideas how to get the soonest dates to post first then post the
nulls?
 
Can you post your code?
You should be able to insert DESC to the end of your Order By clause to get
the earliest dates first, nulls would push to the bottom of the list.
 
Thanks for the response. There is a ton of code but I'll post the relavant
code below. If i do a DESC sort it does push the NULL's to the bottom but it
puts my dates in reverse order (i.e. the latest date first), I need the
soonest date first (i.e. closest to today).

Code:

SELECT p.priority, p.title, IIF(ISNULL(p.due_date),#3/31/2050#,p.due_date)
AS due_date FROM problems as p ORDER BY p.priority DESC, due_date ASC

..... and I get
Null
1/31/2006
2/27/2006

..... if I sort DESC I get
2/27/2006
1/31/2006
Null

..... I want
1/31/2006
2/27/2006
Null

I thought by subbing an extremely distant date for any null value (and then
hide that far out date w/ ASP when writing) it would work but it didnt.

Thanks again,
Scott
 
You are a god! Thanks much!
You are welcome... he says as he ducks the lightning bolts from above... <g>
 
Back
Top