Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:40:34+00:00 2026-06-01T08:40:34+00:00

I have asp.net application and am using Entity Framework to connect it with the

  • 0

I have asp.net application and am using Entity Framework to connect it with the database. in this application, I have a textbox to get the date(am using calender css style here), and its in the string type.

I have a column in my database and its in Date Time format, I need to compare the textbox value with the date column in my database, for this I just used the code as

public StudentAttendances(string date)
    {
        if (date != "")
        {
            DateTime date1 = Convert.ToDateTime(date);

            foreach (DataAccess.StudentAttendance studentAttendance in buDataEntities.StudentAttendances.Where(s => s.Date == date1))
            {
                this.Add(new StudentAttendance(studentAttendance.StudentId));
            }
        }
    }

for example if I select a date in my textbox(the format is 04/05/2012) and when I compare this with the database its not showing any data, but actually some datas are there for this date.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:40:36+00:00Added an answer on June 1, 2026 at 8:40 am

    Your code is comparing both day and time (hours, minutes etc will have to match). Try comparing just the day part like this:

    buDataEntities.StudentAttendances.Where(s => s.Date.Subtract(date1).Days == 0)
    

    I also think that you should specify what format the input date from the users is in.
    04/05/2012 may mean both 4th April or 5th of May depending on your computers regional setting.
    Here is an example (below) for converting a date string in American format to DateTime object:

    DateTime date1 = DateTime.Parse(date, new CultureInfo("en-US"));
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an asp.net application using Entity Framework. In this I want to
I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have
I have an ASP.NET application using an entity framework model. In an import routine,
I have an application developed in ASP.NET MVC using Entity Framework / Sql Server
I have an ASP.NET MVC 3 (using Entity Framework 4.2) application that uses transactions
I have a asp.net application in that I am using ado.net entity framework in
I have a ASP.NET MVC 2.0 application using Entity Framework. All my views use
I have a ASP.NET MVC 3 application, using Entity Framework 4 to handle Data
I have written a small Asp.net application using Entity Framework. A Stored Procedure accepts
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.