Results 1 to 2 of 2

Thread: parsing Date() into database using SQL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    67

    parsing Date() into database using SQL

    Hi all,

    Having a little problem parsing the current date from my vb.net app into access. Both formats are setup as date so i can't see problem. The date.todat format works but comes up with completely the wrong date im truying to use the date.now format. Heres the code see what you think.

    Dim dDate As Date = Date.Now

    cmd.CommandText = "INSERT INTO Faults (userName, userProblem, openDate) Values ('" & strUser & "', '" & strProblem & "', " & dDate & " ) "

    Thanks In Advance!

  2. #2
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    Try This

    VB Code:
    1. Dim dDate As Date = Date.Now
    2. Dim strDate as String
    3.  
    4. strDate = dDate.Tostring("d MMM yyyy HH:mm:ss")
    5. cmd.CommandText = "INSERT INTO Faults (userName, userProblem, openDate) Values ('" & strUser & "', '" & strProblem & "',  '" & strDate & "' ) "

Posting Permissions

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



Click Here to Expand Forum to Full Width