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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:09:24+00:00 2026-06-09T20:09:24+00:00

I”m using EF to query the database using anonymous type. here the code I

  • 0

I”m using EF to query the database using anonymous type.

here the code I use for EF

    public JsonResult OverdueEventsCustom()
    {
        var eventCustomOverdue = _eventCustomRepository.FindOverdueEventsCustom();
        return Json(eventCustomOverdue, JsonRequestBehavior.AllowGet);
    }


    public IQueryable<dynamic> FindOverdueEventsCustom()
    {
        DateTime dateTimeNow = DateTime.UtcNow;
        DateTime dateTomorrow = dateTimeNow.Date.AddDays(1);
        return db.EventCustoms.Where(x => x.DateTimeStart < dateTomorrow)
                    .Select(y => new { y.EventId, y.EventTitle, y.DateTimeStart});
    }

Inspecting using the debugger I see the properties is in this format

Date = {16/08/2012 00:00:00}

The resultfor the JSON is

[{
    "EventId": 1,
    "EventTitle": "Homework Math",
    "DateTimeStart": "\/Date(1345108269310)\/"
}, {
    "EventId": 4,
    "EventTitle": "Homework help with Annie",
    "DateTimeStart": "\/Date(1345108269310)\/"
}, {
    "EventId": 6,
    "EventTitle": "Physic laboratory",
    "DateTimeStart": "\/Date(1345108269310)\/"
}]

I need the the json in this format

"DateTimeStart": "(16/08/2012)"

Any idea what i’m doing wrong here? thanks for your help

Related articles

http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx

How do I format a Microsoft JSON 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-09T20:09:25+00:00Added an answer on June 9, 2026 at 8:09 pm

    "\/Date(1345108269310)\/" is the correct way to pass a Date to javascript. The way I see it, you have two options here:

    If you do not explicitly need the value as a date, you could just pass a string to the JSON variable, containing the pretty-printed date.
    Something along the lines of:

    DateTimeStart: String.Format("{0: dd-MM-yyyy}", myDate)
    

    If you will still need to use the variable a a date in javascript (for calculations for example), the most consice and readably way would be to create a javascript function that converts said date into the pretty-printed string you want (I don’t know if such a function already exists. It isn’t too hard to create though:

    function prettyDate(date) {
    
        return date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear();
    
    }
    

    I would suggest passing it along as a string from you code behind, as it is more readable. But that only works if you do not need to use the date except for displaying.

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

Sidebar

Related Questions

I'm using Socket.IO on Node.js. The Example here: http://socket.io/#how-to-use First Example. I have tested
here i'm trying to execute a code found with google for capturing video from
I am using custom code to print the comments but the problem is whatever
I'm using this code to make #sidebar 's height match #post_content 's height: <script
I'm looking for a way to convert text like this: <!DOCTYPE html PUBLIC \-//W3C//DTD
I have a MYSQL database which needs to be accessed by both PHP and
in this code I'm trying to Listening to multi connection at the same time
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have html encoded strings in a database, but many of the character entities
I have a very basic shell script here: for file in Alt_moabit Book_arrival Door_flowers

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.