locked
Oracle datetime question RRS feed

  • Question

  • User1248258412 posted

    I have problem when insert new record to oracle database.. it keep show "ORA-01843: not a valid month"

    My database field format = "03/12/2012 2:22:13 PM"

    My code as below..

    Dim CreatedDatetime As String

    CreatedDatetime =DateTime.Now

     

    then i insert '"& CreatedDatetime & "'

    in my sql statement.. anyone how to fix this?

    Sunday, June 17, 2012 11:52 PM

Answers

  • User1248258412 posted

    resolve.. i using "sysdate" to insert for CreateDatetime. Thanks...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 18, 2012 2:26 AM

All replies

  • User79986525 posted

    Hi

    try this

    Dim CreatedDatetime As DateTime
    
    CreatedDatetime =DateTime.Now
    
    and please check the format of datetime in CreatedDatetime wether it is in MM/dd/YYYY or not 
    
    else 
    
    try this 
    
    Dim CreatedDatetime As String 
    
    CreatedDatetime =DateTime.Now
    CreatedDatetime =CreatedDatetime.Tostring("MM/dd/yyyy")



    Monday, June 18, 2012 1:29 AM
  • User1248258412 posted

    my database previous record is show in this format 03/12/2012 2:22:13 PM

    so how can i save in the format mm/dd/yyyy hh:mm:ss ? coz i try using tostring also getting "ORA-01843: not a valid month"

    Monday, June 18, 2012 1:33 AM
  • User1501365188 posted

    try this

    http://forums.asp.net/t/1634775.aspx

    Monday, June 18, 2012 1:39 AM
  • User705563967 posted

    In Sql write like this

    '"& to_date( to_char ( CreatedDatetime, 'dd/MM/yyyy' ) , 'dd/MM/yyyy' ) & "'

    it will work 100%

    Monday, June 18, 2012 1:43 AM
  • User1248258412 posted

    try this

    http://forums.asp.net/t/1634775.aspx

     

    try that i getting "String was not recognized as a valid DateTime. "

    Monday, June 18, 2012 1:52 AM
  • User1248258412 posted

    resolve.. i using "sysdate" to insert for CreateDatetime. Thanks...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 18, 2012 2:26 AM