List<DateTime> lstDatesCtcStartDate = new List<DateTime>(
from l in LstAdvancePaymentRep where l.CieDesc.Trim().Equals(lblCieName.Text.Trim()) select l.CtcDtStart.Value.Date
);
Get a List of Dates in lstDatesCtcStartDate How do i find the minimum in this List
SELECT min(CtcDtStart), MAX(CtcDtEnd)fromVwOpenAdvance1 where CieDesc= abc
HI vinikatyal,
You can get max and min date from VwOpenAdvance1 using below code.
MAX DATE :
-----------
var maxDate = (from q in VwOpenAdvance1
where q.CieDesc = "abc"
select d.CtcDtEnd).Max();
MIN DATE :
-----------
var minDate = (from q in VwOpenAdvance1
where q.CieDesc = "abc"
select d.CtcDtStart).Min();
vinikatyal
Member
22 Points
30 Posts
Get the max and min Date values LIST based on a condition
Nov 18, 2012 11:34 AM|LINK
I am getting distinct Company Names through this query
What i want to do is get the Minimum and Maximum Dates for all the companies stored in listCieIdI am new to such queries haven't used them before
EDIT: I am using Distinct to get a the distinct company names as there is a repetition in the LstAdvancePaymentRep
RameshRajend...
Star
7983 Points
2099 Posts
Re: Get the max and min Date values LIST based on a condition
Nov 18, 2012 01:20 PM|LINK
Hai
Check this
http://stackoverflow.com/questions/1107868/linq-min-max
http://www.java2s.com/Code/CSharp/LINQ/GettheMinandmaxvaluefromaquery.htm
vinikatyal
Member
22 Points
30 Posts
Re: Get the max and min Date values LIST based on a condition
Nov 18, 2012 03:34 PM|LINK
List<DateTime> lstDatesCtcStartDate = new List<DateTime>( from l in LstAdvancePaymentRep where l.CieDesc.Trim().Equals(lblCieName.Text.Trim()) select l.CtcDtStart.Value.Date ); Get a List of Dates in lstDatesCtcStartDate How do i find the minimum in this ListRameshRajend...
Star
7983 Points
2099 Posts
Re: Get the max and min Date values LIST based on a condition
Nov 18, 2012 03:39 PM|LINK
Hai
try this
Thank you..matifnadeem
Contributor
4722 Points
1112 Posts
Re: Get the max and min Date values LIST based on a condition
Nov 19, 2012 09:22 AM|LINK
HI vinikatyal,
You can get max and min date from VwOpenAdvance1 using below code.
MAX DATE : ----------- var maxDate = (from q in VwOpenAdvance1 where q.CieDesc = "abc" select d.CtcDtEnd).Max(); MIN DATE : ----------- var minDate = (from q in VwOpenAdvance1 where q.CieDesc = "abc" select d.CtcDtStart).Min();Hope you got what you need. Cheers
M Atif Nadeem
Mark as Answer if you got right thing
Read my blog | Follow me on LinkedIn