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

  • SEARCH
  • Home
  • 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 8012229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:16:01+00:00 2026-06-04T19:16:01+00:00

In my current query I’m having an error like this: The datetime literal value

  • 0

In my current query I’m having an error like this:

The datetime literal value '2012-05-24' is not valid.   

For regular linq query it seems like this:

_listHistory = (from item in dbase.histories
                where item.UserID == details.UserID && item.FriendID.HasValue == true && item.LogDate < today
                select item).OrderByDescending(x => x.LogDate).Take(take).Skip(skip).ToList();  

I will be dealing with number of table “Columns” so I have to use linq predicate:

string predicate = string.Format("it.UserID=={0} && CAST(it.{1} as Edm.Int64) != null  && it.LogDate <= DATETIME'{2}'",
            details.UserID, columnname, string.Format("{0:yyyy-MM-dd}", today));

_listHistory = dbase.histories.Where(predicate)
                .OrderByDescending(x => x.LogDate).Take(take).Skip(skip).ToList();  

But this query result the error above. Can anyone help me to construct my linq query?
It is my first time to deal with Linq predicates and literals.

  • 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-04T19:16:03+00:00Added an answer on June 4, 2026 at 7:16 pm

    You could likely use the dynamic LINQ support instead, but assuming this is Entity Query Language, it appears that you can construct the datetime with a call to CreateDateTime:

    http://msdn.microsoft.com/en-us/library/bb738563.aspx

    CreateDateTime( year, month, day, hour, minute, second)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current LINQ query and example XML are below. What I'd like to do
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
This is my current query - its not getting the required result. I want
My current query looks like this: SELECT * FROM fiberbox f WHERE f.fiberBox LIKE
I want to do a query containing 'like' and 'not like'. Current example: i
My current query looks like this: SELECT DISTINCT (member), count( UID ) AS numUID
My current query looks something like this: SELECT SUBSTR(name,1,1), COUNT(*) FROM files GROUP BY
I'm trying to get the query string from a string (not the current URL).
I am having some confusion with a mysql query. Any help appreciated. My current
I'm new to linq to xml as of today... my current query throws an

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.