Forums
This topic is locked
show based on time selected
Posted 16 Nov 2004 22:24:34
1
has voted
16 Nov 2004 22:24:34 Simon Bloodworth posted:
I have a recordset that holds data for each register customer - what i want to be able to do is allow the user to choose how far back the data should show, similar to the selection on the forums - sow records from last week, last month, last 6 months and so on.How can i do this?
Replies
Replied 16 Nov 2004 23:42:02
16 Nov 2004 23:42:02 Simon Martin replied:
You would need some sort of time stamp against each item of data, then filter your selection to show records where the time stamp was less than the value selected by the user.
For instance each post on the forums has a date it was created (in SQL the GETDATE() function, or NOW() in VB). Then your selection would be something like: SELECT * FROM tblYourTable WHERE postedDate < varYourSelectedValue - where varYourSelectedValue is the selection on the drop down menu.
Each time band on the drop down menu would, therefore, be a value something like DATEADD(d, -7, GETDATE()) for last week, DATEADD(m, -1, GETDATE()) for last month, DATEADD(m, -6, GETDATE()) for last 6 months etc
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
For instance each post on the forums has a date it was created (in SQL the GETDATE() function, or NOW() in VB). Then your selection would be something like: SELECT * FROM tblYourTable WHERE postedDate < varYourSelectedValue - where varYourSelectedValue is the selection on the drop down menu.
Each time band on the drop down menu would, therefore, be a value something like DATEADD(d, -7, GETDATE()) for last week, DATEADD(m, -1, GETDATE()) for last month, DATEADD(m, -6, GETDATE()) for last 6 months etc
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 17 Nov 2004 00:26:36
17 Nov 2004 00:26:36 Simon Bloodworth replied:
i will give that a try, many thanks for your help