|
 |
|
[ ASP.NET ] แปลงข้อมูลเวลา จาก String เป็น Datetime ไม่ได้ครับ |
|
 |
|
|
 |
 |
|
น่าจะได้นะครับ
Code (C#)
DateTime date=DateTime.Parse("11/10/2017");
|
 |
 |
 |
 |
Date :
2017-10-11 16:46:31 |
By :
OOP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาให้ชัดเจน คือเอาไป update ลง Database ใช่ปะ
|
 |
 |
 |
 |
Date :
2017-10-11 16:55:48 |
By :
OOP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ INSERT แบบนี้ไหม
Code (SQL)
SqlConnection conn = new SqlConnection("your connection string");
SqlCommand cmd = new SqlCommand("INSERT INTO table_name (username, logindate) VALUES (@USERNAME, @DATE)", conn);
cmd.Parameters.AddWithValue("@USERNAME", tbUserName.Text);
cmd.Parameters.AddWithValue("@DATE", DateTime.Now);
int i = cmd.ExecuteNonQuery();
หรือไม่ต้องทำ Format ให้มันตรงกับ SQL Server กอ่นครับ ในกรณีที่ เป็น String
Code (C#)
var date = DateTime.Parse("11/10/2560").ToString("MM/dd/yyyy");
|
 |
 |
 |
 |
Date :
2017-10-11 17:04:33 |
By :
OOP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโค้ดหน่อยได้ปะ ข้องใจ
|
 |
 |
 |
 |
Date :
2017-10-11 17:13:43 |
By :
OOP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|