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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:18:22+00:00 2026-06-03T08:18:22+00:00

I am using a datetime picker. I pick a day and save the data

  • 0

I am using a datetime picker. I pick a day and save the data but in my database it saves the value as 1/1/0001 12:00:00 AM. Can anyone tell me why this is?

@model MvcApplication4.Models.Reservation
@using JQueryUIHelpers

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<title>jQuery UI Helpers - @ViewBag.Title</title>
<script src="../../Scripts/jquery-ui.unobtrusive-0.4.0.min.js"   type="text/javascript"></script>
<script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />       

<script src="@Url.Content("~/Scripts/jquery-ui-1.8.19.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.unobtrusive.min.js")" type="text/javascript"></script>   
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <div class="editor-label">
        @Html.LabelFor(model => model.Room.Room_number, "Room")
    </div>

    <div class="editor-field">
        @Html.DropDownList("Room_ID", string.Empty)
        @Html.ValidationMessageFor(model => model.Room.Room_number)
    </div>

    <fieldset>
        <legend class="ui-state-legend-default ui-corner-top ui-corner-bottom">Detalii Client</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Guest_ID, "First Name")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Guest.FirstName)
            <div class="editor-label">
                @Html.LabelFor(model => model.Guest_ID, "Last Name")
            </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.Guest.LastName)
            <div class="editor-label">
                @Html.LabelFor(model => model.Guest_ID, "Phone number")
            </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.Guest.Phone)
            @Html.ValidationMessageFor(model => model.Guest_ID)
        </div>
    </fieldset>

    <fieldset>
        <legend class="ui-state-legend-default ui-corner-top ui-corner-bottom">Perioada rezervare</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Data_Check_in)
        </div>
        <div class="editor-field">
            @(Html.JQueryUI().Datepicker("anotherDate").MinDate(DateTime.Today).ShowButtonPanel(true)
      .ChangeYear(true).ChangeMonth(true).NumberOfMonths(2))
            @Html.ValidationMessageFor(model => model.Data_Check_in)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Data_Check_out)
        </div>
        <div class="editor-field">
            @(Html.JQueryUI().Datepicker("CheckoutDate").MinDate(DateTime.Today).ShowButtonPanel(true)
      .ChangeYear(true).ChangeMonth(true).NumberOfMonths(2))
            @Html.ValidationMessageFor(model => model.Data_Check_out)
        </div>
    </fieldset>
    <div class="editor-label">
        @Html.LabelFor(model => model.Preference_ID, "Preference")
    </div>
    <div class="editor-field">
        @Html.DropDownList("Preference_ID", string.Empty)
        @Html.ValidationMessageFor(model => model.Preference_ID)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model =>model.Price)
    </div>       

    <div class="editor-field">
        @Html.EditorFor(m =>m.Price)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Card_ID, "CreditCard")
    </div>
    <div class="editor-field">
        @Html.DropDownList("Card_ID", String.Empty)
        @Html.ValidationMessageFor(model => model.Card_ID)
    </div>

    <p><input type="submit" value="Create" /></p>
}

Here is my create action:

public ActionResult Create()
{
    ViewBag.Card_ID = new SelectList(db.CreditCards, "CardID", "CardType");
    ViewBag.Guest_ID = new SelectList(db.Guests, "Guest_ID", "FirstName");
    ViewBag.Preference_ID = new SelectList(db.Preferences, "Preference_ID", "Preference_Type");
    ViewBag.Room_ID = new SelectList(db.Rooms, "RoomID", "Room_number");
    return View();
} 

//
// POST: /RS/Create

[HttpPost]
public ActionResult Create(Reservation reservation)
{
    if (ModelState.IsValid)
    {
        db.Reservations.Add(reservation);
        db.SaveChanges();
        return RedirectToAction("Index");  
    }

    ViewBag.Card_ID = new SelectList(db.CreditCards, "CardID", "CardType", reservation.Card_ID);
    ViewBag.Guest_ID = new SelectList(db.Guests, "Guest_ID", "FirstName", reservation.Guest_ID);
    ViewBag.Preference_ID = new SelectList(db.Preferences, "Preference_ID", "Preference_Type", reservation.Preference_ID);
    ViewBag.Room_ID = new SelectList(db.Rooms, "RoomID", "Room_number", reservation.Room_ID);
    return View(reservation);
}
  • 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-03T08:18:24+00:00Added an answer on June 3, 2026 at 8:18 am

    Try to use this, for me it’s more simple.

    in the head section put this :

     <link href="../../Content/css/jquery-ui.css" rel="stylesheet" type="text/css" />
        <link href="../../Content/css/jquery.ui.datepicker.css" rel="stylesheet" type="text/css"/>
    
        <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.ui.datepicker.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery.ui.core.min.js" type="text/javascript"></script>
      <script type="text/javascript">
            $(function () {
                $("#Data_Check_out").datepicker({ dateFormat: 'dd-mm-yy' });
                $("#Data_Check_in").datepicker({ dateFormat: 'dd-mm-yy' });
            });
        </script>
    

    In your view out this :

     <%: Html.LabelFor(model => model.Data_Check_in) %>
            <br />
                <%: Html.EditorFor(model => model.Data_Check_in)%>
                <%: Html.ValidationMessageFor(model => model.Data_Check_in) %>
            <br />
                <%: Html.LabelFor(model => model.Data_Check_out) %>
            <br />
                <%: Html.EditorFor(model => model.Data_Check_out) %>
                <%: Html.ValidationMessageFor(model => model.Data_Check_out) %>
            <br />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Datetime.Minvalue which return 1.1.0001. This value can not be stored to
Possible Duplicate: DateTimePicker: pick both date and time I'm using a WinForm DateTime picker
I've done some simple string -> DateTime conversions before using DateTime.ParseExact(), but I have
I am using a standard date picker to allow the user to pick a
I'm new to c#, in my program im using DateTimePicker Value changed event but
I did this example using the pluralsight video but the date picker is just
I am using jquery datetime picker. it is showing date in yy/MMM/dd hh:mm:ss format
I'm using MVC2 and have included the Jquery DateTime picker. For some reason it
Using Datetime Picker control Datetimepicker control format is 00 (minutes only, upto 59 minutes)
I'm using this datetime picker and want to set the minDate to today at

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.