Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
var std = (from sa in Entities.MBL_MAST_GRIEVANCE

select new
{
sa.Status == "1" ? "Active" : "InActive",
sa.creation_date,
}).ToList();
foreach (var p in std)
{

CMSMobApp edtprod = new CMSMobApp();
edtprod.Status = (p.Status);
edtprod.CreatedDate = p.creation_date.ToString();
obj.Add(edtprod);
}

What I have tried:

Above is My Code-
creation_date is my column where i get datatime data and i want to know how to convert
datetime to date of this created_date Column

one more question -
status is my column name where i get id like 1,2 and there i want to use case
like when 1 then Active else Inactive how to use it in entityframework

please help
Posted
Updated 17-Feb-18 0:26am
Comments
Richard MacCutchan 17-Feb-18 6:12am    
What do you mean by "convert"? A DateTime object is already a Date.
Member 12183079 17-Feb-18 7:07am    
i want to remove time from column

1 solution

It's already a DateTime value - so just remove the ToString call and it should "just work":
edtprod.CreatedDate = p.creation_date; 
 
Share this answer
 
Comments
Member 12183079 17-Feb-18 7:06am    
but i get conversion error datetime to string
OriginalGriff 17-Feb-18 7:13am    
Then your CreatedDate property is not a DateTime value - it's a string.
Fix that - you should always store information in the appropriate datatype, or it becomes a PITA later on.
Member 12183079 17-Feb-18 7:17am    
can i not convert in entityframework

Member 12183079 17-Feb-18 7:17am    
and above i post for case using in column so can you help me

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