Have you ever looked at DateTime?

http://articles.techrepublic.com.com/5100-10878_11-6089546.html
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx

It would make this " currentDateTime = Month(Now()) & "/" & Day(Now())
& "/" & Year(Now())
& " " & Hour(Now()) & ":" & Minute(Now()) & ":" & Second(Now()) " much
easier to read.

You can then change the sql string to be
sql = "DELETE FROM TBLAPPLICATIONLOG WHERE DTMERROR < " &
DateTime.Now.AddDays(-30)

Are you getting any error messages that the deletion is failing?

Put a break point on the Catch statement and see what the value of ex
is.

Step through your code to see if it is breaking somewhere.

On Aug 20, 11:06 am, MM <[email protected]> wrote:
> Hi,
>
> I am trying to delete all entries in a table that are older than 30
> days. Here is my code in VB, can someone tell me how to fix this so
> that it actually does the deletion? thank you
>
> Private Sub clearEventLog()
> Dim sql
> Dim currentDateTime As String
>
> Try
>  currentDateTime = Month(Now()) & "/" & Day(Now()) & "/" & Year(Now())
> & " " & Hour(Now()) & ":" & Minute(Now()) & ":" & Second(Now())
> app.Events.Write("current date: " & currentDateTime)
>             sql = "DELETE FROM TBLAPPLICATIONLOG WHERE DTMERROR < " &
> currentDateTime - 30
>             _dbAccess.executeDbCommand(sql)
>         Catch ex As Exception
>             onError("eventViewer.aspx.vb | clearEventLog() " &
> ex.Message, ex)
>  End Try
>  End Sub

Reply via email to