www.webdeveloper.com
Results 1 to 3 of 3

Thread: ASP Date problem!

  1. #1
    Join Date
    Feb 2004
    Posts
    29

    ASP Date problem!

    Hi,

    I have this code to recoed in an Access table called DeleteLog, when a user deletes a document from another table called Documents. However I cannot get the date to work. I want to knoexactly when the document was deleted. Can anyone help?

    Code:
    <%
    Set rs = Server.CreateObject("ADODB.Recordset")
    vDID = Request.QueryString("DID")
    
    var_date=date() 'get the current date 
    var_date=CStr(FormatDateTime(var_date,1))
    'Response.Write(var_date)
    
    GetDeletedDocument Conn, rs, vDID 'returns all info about the deleted doc
    SQL = ""
    SQL = SQL & "Insert INTO DeleteLog (DeletedFrom, ItemDeleted, User, Date)"
    SQL = SQL & " VALUES "
    SQL = SQL & "('Documents','" & rs("Doc_Title") & "','" & Session("User") & "','" & var_date & "')"
    Conn.Execute(SQL)
    Thanks

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    hmm. The method you have used should return a valid date...

    Try this:
    Code:
    var_date = CDate(Month(Now()) & "-" & Day(Now()) & "-" & Year(Now()))
    response.write (var_date)
    Regards,
    Andrew Buntine.

  3. #3
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Just an add-on,

    You could simply use the Now() method to store the exact date and time the file was deleted.
    Code:
    var_date = Now()
    Finally, its probably best to use cast date (CDate()) rather than cast string (CStr()) in this case since we are dealing with dates.

    Regards. again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles