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 7005527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:21:43+00:00 2026-05-27T21:21:43+00:00

I have to compare a user entered date, Dt (in mm/dd/yyyy format) with the

  • 0

I have to compare a user entered date, “Dt” (in mm/dd/yyyy format) with the date in RavenDB – “ReleaseDate” (time stamp like “/Date(1187668800000)/”). For this I am using the following code which almost gets the job done, but I need little help to finalize loose ends…

How can I compare the two dates so I can get the query to run successfully.

    public ActionResult Calculation(DateTime? Dt)
    {             
        var store = new DocumentStore { Url = "http://localhost:80" };
        store.Initialize();

        var CalcModel = new CalcViewModel();

        using (var session = store.OpenSession())
        {       
         //Converting user entered date dt in mm/dd/yyyy format to total 
         //milliseconds - So that later I can compare this value to RavenDB
         //time stamp date format (older versions)

          DateTime d1 = new DateTime(1970, 1, 1);
          DateTime d2 = Dt.Value.ToUniversalTime();
          TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);

          double tmillisecs = ts.TotalMilliseconds; //Not yet using this value. 

          CalcModel.MoviesByDate = session.Query<Movies>()
                                   .Where(x => x.ReleaseDate.Ticks == ts.Ticks)            
                                   .Count();

          // this is where I need to compare two dates - ts.ticks gives the
          // required value of date (1187668800000) multiplied by 10000.
        }

        return View(CalcModel);

    }

Right now, when I debug I know what value ts.ticks is showing… and its like I said above in the code comments, the required value multiplied by 10000. But I have no clue at run time , what the value in x.ReleaseDate is or x.ReleaseDate.Ticks is.. am I doing this correctly. Thanks for the help.

  • 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-05-27T21:21:44+00:00Added an answer on May 27, 2026 at 9:21 pm

    Umm… I think you seriously misunderstand how SQL dates work, and how it applies to .NET. The whole point about dates is that they’re stored in a numeric format, not a text one. So when you have a DateTime object, it’s not stored as the text date, it’s stored as a numeric type that you can convert to any format you want.

    Because the .net provider converts database native datetime objects to DateTime objects, you can just compare them natively. ie:

    DateTime d1 = new DateTime(1970, 1, 1);
    CalcModel.MoviesByDate = session.Query<Movies>()
                                   .Where(x => x.ReleaseDates.Date == d1.Date)
                                   .Count();
    

    Regardless of how RavenDB stores the dates internally, when the DateTime object is materialized in the query, it will be in native .NET format.

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

Sidebar

Related Questions

I have a class user which looks like this: public class User { public
I am using this to compare the password entered and the confirm password. No
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
I have this code: # Compare phone number phone_pattern = '^\d{3} ?\d{3}-\d{4}$' phoneNumber =
I have been using SQL Compare by Redgate at my company and was very
I am using a compare validator, which validates that the entered number is a
I have a time in hh:mm and it has to be entered by the
I have two email fields on a form to validate that the user entered
I have this change password request form.In which the user enter their oldpasswords. this
I have stored user passwords in an encrypted format in my database. However, now

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.