TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Smart Lucky
NA
555
637.7k
DateTime Format Problem Not Getting Exact Result
Jan 30 2014 12:30 AM
Hi dudes
i am using here one method and it is getting to perameters nullable DateTime type i want to get those records whoes created date match with my paremters
( i am using here view which returning date in this format (2014-01-29) ) ,and when i am passing start date (value of startDate is compalete datetime means it is {1/30/2014 12:00:00 AM}) , that's why it is not showing my complete records. please help me.
public IList<GetCompanybyClicks> GetCompanyByClicks(DateTime? startDate, DateTime? endDate)
{
var data = session.Query<GetCompanybyClicks>().ToList();
// var test = Convert.ToDateTime(Convert.ToDateTime(startDate).Date.ToString("yyyy-mm-dd"));
if (!string.IsNullOrWhiteSpace(startDate.ToString()) && !(string.IsNullOrWhiteSpace(endDate.ToString())))
{
data = data.Where(x => x.createddate >= startDate && x.createddate <= endDate).Distinct(x => x.Name).ToList();
}
if ((!string.IsNullOrWhiteSpace(startDate.ToString()) && (string.IsNullOrWhiteSpace(endDate.ToString()))))
{
data = data.Where(x => x.createddate >= startDate).Distinct(x => x.Name).ToList();
}
if ((string.IsNullOrWhiteSpace(startDate.ToString()) && (!string.IsNullOrWhiteSpace(endDate.ToString()))))
{
data = data.Where(x => x.createddate <= endDate).Distinct(x => x.Name).ToList();
}
if ((string.IsNullOrWhiteSpace(startDate.ToString()) && (string.IsNullOrWhiteSpace(endDate.ToString()))))
{
data = data.Where(x => x.createddate > DateTime.Now.AddDays(-7)).Distinct(x => x.Name).ToList();
}
return data;
}
Reply
Answers (
2
)
How to Match only four Character of a field in linq????
Update the list object using linq