Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format datetime error #1864

Open
overlinejota opened this issue Jul 31, 2024 · 0 comments
Open

Format datetime error #1864

overlinejota opened this issue Jul 31, 2024 · 0 comments

Comments

@overlinejota
Copy link

Problem description and reproducible code:

Format datetime error


public class TableSample {
	[Column(IsIdentity = false, IsPrimary = true)]
	public int Id { get; set; } 
	public DateTime TimeStamp { get; set; }
}

var fsql= new FreeSql.FreeSqlBuilder()...
var formatDate = fsql.Ado.QuerySingle<string>("SELECT r.date_format FROM master.sys.dm_exec_requests r WHERE r.session_id = @@SPID");
// formatDate = "dmy"

int id = 1;
var sql = fsqlSage.Update<TableSample>(id).Set(x => x.TimeStamp, DateTime.Today).ToSql();
//  sql= "UPDATE [TableSample] SET [TimeStamp] = '**2024-07-30** 00:00:00.000' WHERE ([Id] = 1)" 
//  SqlException: convert varchar to datetime.
//  correct: "UPDATE [TableSample] SET [TimeStamp] = '**30-07-2024** 00:00:00.000' WHERE ([Id] = 1)" 

Database version

SQLEXPRESS 15.0.20000

Nuget

FreeSql.All 3.2.832

.net framework/.net core? y versión específica

.Net 8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant