How to format dates in queries?
Examples:
myTable.Select( x=> x.myDate.ToString("yyyy-MM-dd") ).Dump() ;
or
myTable.Where( x=> x.myDate.ToString("yyyy-MM-dd") == "2020-01-01" ).Dump() ;
Examples:
myTable.Select( x=> x.myDate.ToString("yyyy-MM-dd") ).Dump() ;
or
myTable.Where( x=> x.myDate.ToString("yyyy-MM-dd") == "2020-01-01" ).Dump() ;
Comments
What are you asking?
If you want to make yyyy-MM-dd the default, you can do so in Edit | Preferences > Results.
Hi friend,
That was just an example. In fact, there will be several formats throughout the code.
yyyy-MM-dd
yyyyMMdd
yyyyMM
Is it possible to do inside the code?
You should treat dates as date in sql, not string. Format the date outside sql and parse the date before using in query:
Very good. Thank you.