We help IT Professionals succeed at work.

my date between is not getting me the correct records

lulu50
lulu50 asked
Hi,

My between date is not working

I'm only getting one record instead of three

I don't know what I'm doing wrong.

I tried without parsing it and that didn't work.

        public DateTime FromCreatedDate { get; set; }
        public DateTime ToCreatedDate { get; set; }

list = list.Where(x => x.CreatedDate >= DateTime.Parse(model.FromCreatedDate.ToString()) && x.CreatedDate <= DateTime.Parse(model.ToCreatedDate.ToString()));

Open in new window

Comment
Watch Question

Software Team Lead
try this instead:
        public DateTime FromCreatedDate { get; set; }
        public DateTime ToCreatedDate { get; set; }

list = list.Where(x => x.CreatedDate >= model.FromCreatedDate && x.CreatedDate <= model.ToCreatedDate);

Open in new window

lulu50Web application

Author

Commented:
Thank you Ryan for your help