Hi friends,
query.Append("SELECT Name, Sex, Marital_Status, Dob, Anniversary, Mobile, Email FROM Client WHERE ");
if (startDate > new DateTime() && endDate > new DateTime())
{
query.Append("(DATEADD(YEAR,DATEDIFF(YEAR, DOB,'" + startDate + "'),DOB) BETWEEN '" + startDate + "'AND'" + endDate + "' OR DATEADD(YEAR,DATEDIFF(YEAR, ANNIVERSARY,'" + startDate + "'),ANNIVERSARY) BETWEEN '" + startDate + "'AND'" + endDate + "') AND ");
}
if (!string.IsNullOrEmpty(maritalStatus) && !string.Equals("All", maritalStatus))
{
query.Append(" Marital_Status = '" + maritalStatus + "'");
}
string resultQuery = query.ToString();
if (resultQuery.Trim().EndsWith("AND", StringComparison.OrdinalIgnoreCase))
{
int lastIndex = resultQuery.LastIndexOf("AND");
resultQuery = resultQuery.Remove(lastIndex, 3);
}
if (resultQuery.Trim().EndsWith("WHERE"))
{
int lastIndex = resultQuery.LastIndexOf("WHERE");
resultQuery = resultQuery.Remove(lastIndex, 5);
}
return resultQuery.Trim();
}
I have used above code, This code working properly, but It shows randomly,
I need,
The Data should have to display in ascending order based on the Date and month.