Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View last 7 days of a dbase datetable

Status
Not open for further replies.

XTRO

IS-IT--Management
Jan 20, 2002
15
0
0
US
I would like to know how i can view the last 7 days off an database table without the problem i now have.

Last 7 days work fine except the last day off the month

example: it is day 30 + 1 but the month only has 30. When it the first day off the month it works fine because it counts correctly

(access will be mySQL in the near future) for now it is access

Listing:

var_datemax = Month(Now()) & "/" & Day(Now())+1 & "/" & Year(Now())
var_datemin = dateadd("d",-8,var_datemax)

Response.Write(&quot;<font class='fixed18b'>Nieuwsblad Transport newsletters : <br></font>&quot;)
Response.Write(&quot;<font class='fixed12r'>(From &quot; & var_datemin & &quot; till &quot; & var_datemax & &quot;)<BR><br>&quot;)

'open recordset to show newsletters
set recordset = server.CreateObject(&quot;ADODB.recordset&quot;)
strConn = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Request.ServerVariables(&quot;APPL_PHYSICAL_PATH&quot;) & &quot;upload.mdb&quot;
strSQL = &quot;SELECT * From ListFiles Where UploadDT Between #&quot; & var_datemin & &quot;# And #&quot; & var_datemax & &quot;# ORDER BY UPLOADDT DESC&quot;
recordset.open strSQL,strConn,1,2

Do until recordset.EOF
response.Write(&quot;<a href='&quot; & Recordset(&quot;DestFileName&quot;) & &quot;' class='fixed12b'>&quot; & Recordset(&quot;description&quot;) & &quot;</a>&quot;)
response.Write &quot; (&quot; & recordset(&quot;UploadDT&quot;) & &quot;)&quot;
response.Write(&quot;<BR>&quot;)
recordset.MoveNext
loop

recordset.Close
Response.Write(&quot;<a href='showall.asp' class='fixed10b'><br>Show all newsletter<br></a>&quot;)
Response.Write(&quot;<br><br>&quot;)
'Response.Write(&quot;<a href='db-file-to-disk.asp' class='fixed10b'>Upload a new newsletter<br></a>&quot;)
Response.Write(&quot;<br><br><br>&quot;)
Response.Write(&quot;</table>&quot;)
Response.Write(&quot;<br><br>&quot;)
Response.Write(&quot;<a href='login.asp' class='fixed10b'> Upload a new NTMAIL newsletter</a>&quot;)

Set Recordset = nothing
 
> var_datemax = Month(Now()) & &quot;/&quot; & Day(Now())+1 & &quot;/&quot; & Year(Now())
> var_datemin = dateadd(&quot;d&quot;,-8,var_datemax)

Why do you use dateadd for the min date and not for the max date? If you use dateadd for the max date and then format it you wont get the problem of having 31 days in a month that only has 30.




----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Thanks, for helping an beginner in ASP i changed it in the following. Tomorrow I will be able to test it X-)
 
Thanks, for helping an beginner in ASP i changed it in the following. Tomorrow I will be able to test it X-)

var_datemax = dateadd(&quot;d&quot;,+1,Month(Now()) & &quot;/&quot; & Day(Now()) & &quot;/&quot; & Year(Now()))
 
Note: you will have to do the formatting after you have added the 1 day onto the date as dateadd will convert the string into the default date format.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top