Forums

This topic is locked

Show records based on current month

Posted 08 Nov 2001 05:43:55
1
has voted
08 Nov 2001 05:43:55 Stuart Chase posted:
I have a query that totals individual records under a person's name. Then I have a page that displays those results in reverse order (highest first). But I only want it to count and show the records for the given month it is. For example, if it is 12:01 AM on December 1st. Chances are no records will be entered so everyone will show zero. but as the month goes on, records begin to show.

any ideas?

Replies

Replied 08 Nov 2001 12:45:55
08 Nov 2001 12:45:55 Owen Eastwick replied:
You could set up a little bit of VBScript to give you the frist day of the month:

<%
varYear = Year(Now)
varMonth = Month(Now)
varStartMonth = "01/" & varMonth & "/" & varYear & " 00:00:00"
%>

You may have to mess around with this to get it to give you a date/time that matches the format in your DB table.

Then use varStartMonth as part of the WHERE clause in your SELECT statement, something like:

SELECT * FROM MyDatabaseTable
WHERE MyDateField >= & "#" & varStartMonth & "#"

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 08 Nov 2001 14:42:39
08 Nov 2001 14:42:39 Stuart Chase replied:
Thank you Owen, I will give that a shot.

Replied 13 Nov 2001 13:46:57
13 Nov 2001 13:46:57 Stuart Chase replied:
Running into a brick wall. I origionally had Access running a query totalling all the individual names with their respective value's in the columns. but that totalls everything - not the current month or month specific.

Would it be better for me to have asp pull and sum by the month? I can get it to at least sum in Access - but havn't figured that out yet in ASP/UltraDev.

Any ideas?

Replied 13 Nov 2001 14:44:00
13 Nov 2001 14:44:00 Owen Eastwick replied:
Try something like:

SELECT SUM(YourNumericField) AS MySum
FROM YourTableName
WHERE YourDateField >= DateAdd("m",-1,Now())

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 13 Nov 2001 16:16:47
13 Nov 2001 16:16:47 Viktor Farcic replied:
Create Query that will calcute latest available month and then other query that will restrict data to that month.

Replied 28 Nov 2001 16:47:17
28 Nov 2001 16:47:17 Stuart Chase replied:
Got it, thanks for the help all. Ended up doing a Access Query on a Access Query. Probably not the most efficient method, but it works.

Reply to this topic