Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 21, 2012 12:57 AM by Decker Dong - MSFT
Member
120 Points
220 Posts
Dec 20, 2012 10:48 AM|LINK
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date+" "+p.End_Date+" "+p.Branch };
i want p.Start_Date in "dd" format and p.End_Date in "dd-MMM" Format. plz guide
Participant
1459 Points
643 Posts
Dec 20, 2012 10:58 AM|LINK
Have a look at http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
942 Points
178 Posts
hi check this one
select new { Id = p.Event_Id , Event = p.Type +" "+Start_Date=p.Start_Date.ToString("dd")+" "+End_Date=p.End_Date.ToString("dd-MMM")+" "+p.Branch };
Dec 20, 2012 11:02 AM|LINK
NadeemZee
Tried This.
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date.ToString("dd")+" "+p.End_Date+" "+p.Branch };
Error
No overload for method 'ToString' takes 1 arguments .
Dec 20, 2012 11:03 AM|LINK
Thanks For your Reply
How to do it in Linq?? Nick Asiimwe
All-Star
118619 Points
18779 Posts
Dec 21, 2012 12:57 AM|LINK
Hi,
Shanker_YPSS Shanker_YPSS
If your Start_Date is DateTime? This means your Start_Date is Nullable<DateTime>. So you can just try this method:
by checking whether the DateTime value is empty or not.
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date .HasValue?p.Start_Date .ToString("dd-MM"):string.Empty+" "+p.End_Date+" "+p.Branch };
Shanker_YPSS
Member
120 Points
220 Posts
Re:Date Formatting in Linq Select Query
Dec 20, 2012 10:48 AM|LINK
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date+" "+p.End_Date+" "+p.Branch };
i want p.Start_Date in "dd" format and p.End_Date in "dd-MMM" Format. plz guide
</div>Nick Asiimwe
Participant
1459 Points
643 Posts
Re: Re:Date Formatting in Linq Select Query
Dec 20, 2012 10:58 AM|LINK
Have a look at http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Sincerely,
Nick
ASP.NET, SQL Server [Database Engine, SSIS & SSRS],Entity Framework, C# and VB.NET
NadeemZee
Participant
942 Points
178 Posts
Re: Re:Date Formatting in Linq Select Query
Dec 20, 2012 10:58 AM|LINK
hi check this one
select new { Id = p.Event_Id , Event = p.Type +" "+Start_Date=p.Start_Date.ToString("dd")+" "+End_Date=p.End_Date.ToString("dd-MMM")+" "+p.Branch };Do FEAR (Face Everything And Rise)
Please mark as Answer if my post helps you..!
Shanker_YPSS
Member
120 Points
220 Posts
Re: Re:Date Formatting in Linq Select Query
Dec 20, 2012 11:02 AM|LINK
NadeemZee
Tried This.
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date.ToString("dd")+" "+p.End_Date+" "+p.Branch };
Error
No overload for method 'ToString' takes 1 arguments .
Shanker_YPSS
Member
120 Points
220 Posts
Re: Re:Date Formatting in Linq Select Query
Dec 20, 2012 11:03 AM|LINK
Thanks For your Reply
How to do it in Linq?? Nick Asiimwe
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Re:Date Formatting in Linq Select Query
Dec 21, 2012 12:57 AM|LINK
Hi,
If your Start_Date is DateTime? This means your Start_Date is Nullable<DateTime>. So you can just try this method:
by checking whether the DateTime value is empty or not.
select new { Id = p.Event_Id , Event = p.Type +" "+p.Start_Date .HasValue?p.Start_Date .ToString("dd-MM"):string.Empty+" "+p.End_Date+" "+p.Branch };