locked
How to insert current date from frontend to database RRS feed

  • Question

  •  

    Hello all,

     

    I read current date into a label using code 

    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

    label1.Text = Convert.ToString(DateTime.Now.ToString());

    Now I am trying  to insert current date into table having column of datatype 'date' .

    But it is raising error "Invalid Month" ie I have to insert month in 'mon' format (Eg:'dec','nov') because date format in oracle is dd-mon-yyyy.

    How can I convert current date into above format and insert into database

     

    Help me,

     

    Thanking You,

    Rajesh 

     

     

     

     

     

    Wednesday, December 19, 2007 4:36 PM

Answers

  • HI, Rajesh

     

    The format string you demanded is "dd-mmm-yyyy", and you can find the detailed information about various formats in the following link:

     http://msdn2.microsoft.com/en-us/library/zdtaw1bw(VS.80).aspx

     

    Also you may try converting the string to a DateTime object and pass this object as parameters for sql commands.

     

    Best Regards

    Chunsheng Tang

    Friday, December 21, 2007 8:37 AM

All replies

  •  

    use getdate() for current date, that way it's the correct one at the database.

     

    Wednesday, December 19, 2007 4:59 PM
  • HI, Rajesh

     

    The format string you demanded is "dd-mmm-yyyy", and you can find the detailed information about various formats in the following link:

     http://msdn2.microsoft.com/en-us/library/zdtaw1bw(VS.80).aspx

     

    Also you may try converting the string to a DateTime object and pass this object as parameters for sql commands.

     

    Best Regards

    Chunsheng Tang

    Friday, December 21, 2007 8:37 AM