Author |
Topic |
|
AliasMoze
New Member
USA
55 Posts |
Posted - 08 August 2002 : 18:48:21
|
I'm working on a very simple Blog solution that pulls from a particular Snitz Category.
My problem is as follows. A common Blog function is an Archive showing the previous years and months. Now, I'm not worried about generating this list dynamically, because it needs updating maybe once a month.
But how can I filter records by year and month. I wouldn't ask if I hadn't tried everything I know, so I'll throw myself at your feet and beg for an answer. |
|
dayve
Forum Moderator
USA
5820 Posts |
|
AliasMoze
New Member
USA
55 Posts |
Posted - 08 August 2002 : 19:22:45
|
Dayve, thanks. I guess what I need to know is how to write a SQL query for filtering the records. If what I just said is a bad idea, please let me know.
Alternatively, I would pull ALL the records, check their dates, and just print the ones that matched.
Which method is better. |
|
|
AliasMoze
New Member
USA
55 Posts |
Posted - 08 August 2002 : 19:25:34
|
Smurf me. Or is it a better idea to put together a date string, say
20010803123408,
and then compare it to the date in the field? If so, do I do this with a WHERE commmand? If so, how?
Thanks again. |
Edited by - AliasMoze on 08 August 2002 19:27:09 |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 08 August 2002 : 19:33:16
|
off the top of my head, Snitz does have a function to convert this, I think it is something like StrToDate(strDateTime). I don't have source code in front of me right now but it would be in the inc_functions.asp and you could use that routine to possibly do some date matching.
Are you just trying to compare Year or full date? If you need the full date it would be something like
strDate = mid(dateField,7,2) & "/" & mid(dateField,5,2) & "/" & mid(dateField,1,4)
this would give you MM/DD/YYYY
http://www.burningsoulsforum.com · Snitz Specs · Snitz Mods · Do's and Dont's |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 08 August 2002 : 19:36:30
|
You can retreive the records with the sql in the following Format.
strSql = "" & _ "SELECT [FIELDS] " & _ "FROM [TABLENAME] " & _ "WHERE [CATIDFIELD]=" & CATID " AND [DATEFIELD] LIKE '" & YYYY & MM & "__________' " & _ "ORDER BY Left([DATEFIELD],6);"
Note: __________ is 8 underscores (_)
<EDIT>
www.forumSquare.com - Rakesh Jain - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
Edited by - GauravBhabu on 08 August 2002 19:42:21 |
|
|
AliasMoze
New Member
USA
55 Posts |
Posted - 08 August 2002 : 19:36:58
|
I'm trying to get the topics from the database that match a particular month and year.
Hey, I just saw you there, Gaurav. I think you have it! Thank-you. I grovel at your feet. You too Dayve. |
Edited by - AliasMoze on 08 August 2002 19:40:00 |
|
|
AliasMoze
New Member
USA
55 Posts |
Posted - 08 August 2002 : 19:56:51
|
Gaurav, Do I actually put "________" (underscores) in the SQL query?
AliasMoze "That activates my hilarity unit." |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 08 August 2002 : 19:59:29
|
Yes
www.forumSquare.com - Rakesh Jain - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
|
Topic |
|