Sonali Avhad

Sonali Avhad

  • NA
  • 234
  • 42.8k

how to add current date and time to datacolumn of datatable in asp.net

Sep 30 2020 2:53 AM
I want to save current date and time . i am adding it into datacolumn.but it giving error for IMPORT_DATE_TIME.
 
My Code in cs file is as follow
  1. DataTable dt = new DataTable();  
  2. dt.Columns.AddRange(new DataColumn[3] {  
  3. new DataColumn("SRNO"typeof(Int32)),  
  4. new DataColumn("BANKID"typeof(Int32)),  
  5. new DataColumn("IMPORT_DATE_TIME",typeof(DateTime),System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"))  
  6. });  
It gives error Syntax error: Missing operand after '13' operator.

Answers (4)