Posts_per_Year

Gets list of years and total of posts per year from a table, by using date column, passing table name and column name with date to summarize by.
Returns Year{{$C$}}45{{$R$}}2007{{$C$}}44{{$R$}}...

Function Posts_per_Year(TableName, DateColumn)
 FSQL = "SELECT yoyo, SUM(coco1) AS coco FROM (SELECT YEAR(" & DateColumn & ") AS yoyo, COUNT(*) AS coco1 FROM " & TableName & " GROUP BY " & DateColumn & ") AS derivedtbl_1 GROUP BY yoyo ORDER BY yoyo DESC"
 set recF = connection.execute(fSQL)
 Do Until recF.Eof
  GGe = GGe & trim(recF("yoyo")) & "{{$C$}}" & trim(recF("coco")) & "{{$R$}}"
  recF.MoveNext
 Loop
 Posts_per_Year = GGe
End Function

TableName, DateColumn

Views 1015 Downloads 336

'Connection', 'SQL', 'DB', 'Database', 'Date', 'Year', 'Summarize', 'total', 'column', 'table', 'ANString', 'ANStr', 'ANSList'

ANmarAmdeen
333
Date+Time Classic ASP
Revisions

v1.0