Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6566959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:16:45+00:00 2026-05-25T14:16:45+00:00

I had try several type of date format and yet, I stil can’t get

  • 0

I had try several type of date format and yet, I stil can’t get it right.

Below are the coding which had been writen

Dim serverDate As String = Format(Now(), "DD-MM-YYYY")
strNew &= "INSERT INTO Staff ("
            strNew &= "full_name"
            strNew &= ", login_id"
            strNew &= ", passwd"
            strNew &= ", last_update"
            strNew &= ") VALUES ("
            strNew &= "'" & txt_Name.Text & "'"
            strNew &= ", '" & txt_Login.Text & "'"
            strNew &= ", '" & txt_Password.Text & "'"
            strNew &= ", (STR_TO_DATE('" & serverDate & "', '%d-%m-%Y'))"
            strNew &= ")"

Any idea what had I missed out?.. Helps are much appreciated..

Edit #1:
Forgot to add in the error message
“Incorrect datetime value :’DD-09-YYYY’ for function str_to_date”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:16:46+00:00Added an answer on May 25, 2026 at 2:16 pm

    You are using hard-coded sql string so you need to use yyyy-MM-dd format date.

    Dim serverDate As String = DateTime.Now.ToString("yyyy-MM-dd")
    
    strNew &= "INSERT INTO Staff ("
                strNew &= "full_name"
                strNew &= ", login_id"
                strNew &= ", passwd"
                strNew &= ", last_update"
                strNew &= ") VALUES ("
                strNew &= "'" & txt_Name.Text & "'"
                strNew &= ", '" & txt_Login.Text & "'"
                strNew &= ", '" & txt_Password.Text & "'"
                strNew &= ", '" & serverDate & "'"
                strNew &= ")
    

    EDIT:

    @BlurrieBlue :
    Forgot to add in the error message “Incorrect datetime value
    :’DD-09-YYYY’ for function str_to_date”

    Yes it is incorrect format. It should be

    Format(Now(), "dd-MM-yyyy")
    

    Take a look at this code-snippet

    cmd=new MySqlCommand()
    cmd.Connection=cn
    cmd.CommandText="INSERT INTO Staff (?full_name,?login_id,?passwd,?last_update)"
    cmd.Parameters.Add("?full_name", MySql.Data.MySqlClient.MySqlDbType.VarChar).Value =txt_Name.Text
    cmd.Parameters.Add("?login_id", MySql.Data.MySqlClient.MySqlDbType.VarChar).Value =txt_Login.Text
    cmd.Parameters.Add("?passwd", MySql.Data.MySqlClient.MySqlDbType.VarChar).Value =txt_Password.Text
    cmd.Parameters.Add("?last_update", MySql.Data.MySqlClient.MySqlDbType.DateTime).Value =DateTime.Now
    
    cn.Open()
    cmd.ExecuteNonQuery()
    cn.Close()
    

    Off-topic: Don’t use hard-coded sql string. Use parameterized sql statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I had an open-source project which I wanted to try and generate some
I had try to implement the send me log feature into my apps but
Possible Duplicate: How to catch exceptions I have not really had to use try
Had a good search here but can't see anything that gets my mind in
I had this problem before and can't for life of me remember how to
This is a problem I've had several times when trying to create layouts with
i am trying to show an image directly under a text which i had
First, I can't speak ENGLISH very well.. please understand :) When I try to
Recently I had to develop several web applications. I did extensive research regarding JavaScript
So I have an array with objects which each have several attributes including an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.