Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
dear sir,

Help me how to convert LINQ datetime Format

Example:


1, Tuesday, 26 January 2012 (or)


2, Tue, 26 Jan 2012


Give me solutions?

By mohan
Posted
Updated 20-Aug-19 8:26am
Comments
[no name] 6-Dec-11 0:05am    
share your code and we will modify it for you.
D K N T H 6-Dec-11 2:59am    
may we see ur codes?
Mohankumar.Engain 6-Dec-11 3:37am    
I want output in LINQ is, 'Tuesday, 01 January 2012'.

var selectQuery=(from add in db.address
select new AddressProperties()
{
date=add.myDate //here how to get
//Like Tuesday, 01 January 2012
//(or) Tue, 01 Jan 2012.
}).Distinct();

Reply me

By mohan.

VB
YearMonth = r.SomeDateTime.ToString("dddd, MMMM yyyy")
 
Share this answer
 
the linq doest know convert, "ToString()" methods so when you are getting the data use enumerable like
var selectQuery = from add in db.address.asEnumerable() ;

then now you can use convert or "tostring" methods.
 
Share this answer
 
(from classname in time.table select t.Date).ToList().Select(d => d.ToString("yyyy-MM-dd");
try it works .......
 
Share this answer
 
C#
var selectQuery=from add in db.address
                 select add.myDate.toString("{0:dddd, MMMM d, yyyy}");

selectQuery.Distinct();


try this..


Regards,
nishant
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900