Forums
This topic is locked
sorting by date...
Posted 15 Jun 2002 21:13:22
1
has voted
15 Jun 2002 21:13:22 Kristian Waagsboe posted:
Server Model: ASP JSA quick search througout the forum was not enough yet againg. I have this calendar function on my site the advanced sql looks like this:
SELECT *
FROM kalender
ORDER BY dato ASC
ORDER BY dato does nothing good at all. It just selects the lowest value (I use DD/MM/YYYY). So how can I order by date???
Replies
Replied 17 Jun 2002 12:32:50
17 Jun 2002 12:32:50 Kristian Waagsboe replied:
It would also be nice to fix it so that if we have passed the date, the record will not be shown..
Replied 17 Jun 2002 12:37:39
17 Jun 2002 12:37:39 Julio Taylor replied:
what database are you using? (e.g. Access, MySQL, MSQL etc.)
i hope this helps.
--J
P.S. i killed kenny
i hope this helps.
--J
P.S. i killed kenny
Replied 17 Jun 2002 17:29:43
17 Jun 2002 17:29:43 Andrew Watson replied:
If your date field is defined as a date at the database then your code should work fine. For yur next bit just add...
AND dato <= Date()
to your SWL
:: Son, im Thirty.... ::
AND dato <= Date()
to your SWL
:: Son, im Thirty.... ::
Replied 18 Jun 2002 13:54:57
18 Jun 2002 13:54:57 Kristian Waagsboe replied:
I'm using MS Access XP.
In access I use =Date() to automatical add the date. It comes out id DD/MM/YYYY format if I'm not quite mistaken. When DW is about to sort it, it sorts after DD which means that 01/12/2002 will come before 05/08/2002. That's the problem. Anybody know a workaround for this one?
In access I use =Date() to automatical add the date. It comes out id DD/MM/YYYY format if I'm not quite mistaken. When DW is about to sort it, it sorts after DD which means that 01/12/2002 will come before 05/08/2002. That's the problem. Anybody know a workaround for this one?
Replied 18 Jun 2002 14:14:54
18 Jun 2002 14:14:54 Kristian Waagsboe replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
If your date field is defined as a date at the database then your code should work fine. For yur next bit just add...
AND dato <= Date()
to your SWL
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I defined it as a date. I have 3 records right now for testing purposes. One May 16th, one June 21st and one June 22nd. Still the one in May is showing. And the sorting is not figured out jet either. It shows 22nd before 21st, but the May record is on the top.
If your date field is defined as a date at the database then your code should work fine. For yur next bit just add...
AND dato <= Date()
to your SWL
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I defined it as a date. I have 3 records right now for testing purposes. One May 16th, one June 21st and one June 22nd. Still the one in May is showing. And the sorting is not figured out jet either. It shows 22nd before 21st, but the May record is on the top.
Replied 18 Jun 2002 14:38:58
18 Jun 2002 14:38:58 Andrew Watson replied:
In access your date field should be a 'date/time ' type. ( it is, you say !) and its default value in access should be Date()
then your recordset source will be this...
<pre id=code><font face=courier size=2 id=code>
Recordset.Source = "SELECT * FROM MyTable WHERE DateField >= #" & Date() & "# ORDER BY DateField ASC"
</font id=code></pre id=code>
This does work, if it doesn't check your regional settings and stuff.
Cheers
Leed
:: Son, im Thirty.... ::
then your recordset source will be this...
<pre id=code><font face=courier size=2 id=code>
Recordset.Source = "SELECT * FROM MyTable WHERE DateField >= #" & Date() & "# ORDER BY DateField ASC"
</font id=code></pre id=code>
This does work, if it doesn't check your regional settings and stuff.
Cheers
Leed
:: Son, im Thirty.... ::
Replied 19 Jun 2002 00:32:08
19 Jun 2002 00:32:08 Kristian Waagsboe replied:
YES!
That one is working FINE. Thanks for support
That one is working FINE. Thanks for support