overflow on DateTime

Topics: General, Troubleshooting
Feb 6, 2012 at 9:48 AM

Knowing that this is probably not a Orchard issue somebody might be able to give me some hints!
I took the Orchard Doc sample "Creating a module with a simple text editor" which worked fine
Then I adapted the same ample using a 'Date'(DateTime) field which (on ContentType => Create new Eve) causes below error:
          [SqlCeException (0x80004005): An overflow occurred while converting to datetime.]
          [GenericADOException: could not insert: [Eve.Models.EvePartRecord#113][SQL: INSERT INTO Eve_EvePartRecord (Evenement, Category, HomeTeam, GuestTeam, Date, DateToEnroll, TeeTime, Captain, Change, Comment, Id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]]
The 'date' field (on ContentType => Create new Eve) shows '01.01.0001 00:00:00' ; I would like to see something formatted like {0:dd-MM-yyyy}!
The EvePartRecord (sqlCE DB) shows all fields (right now NULLS; I guess due to the error this is correct)

There are all kind of threads discussing dateTime conversion - which didn't help!

? are there any special considerations on this subject in Orchard / SqlCE?

Below the relevant definitions.
Thanks for your time, ed

@model Eve.Models.EvePart
    <label class="sub" for="Evenement">@T("Evenement")</label>
    @Html.TextBoxFor(m => m.Evenement, new { @class = "text" })<br />
    <label class="sub" for="Date">@T("Date")</label>
    @Html.TextBoxFor(m => m.Date)<br />

Data Model:
namespace Eve.Models {
    public class EvePartRecord : ContentPartRecord {
        public virtual string Evenement { get; set; }
        public virtual DateTime Date { get; set; }
    public class EvePart : ContentPart<EvePartRecord> {
        public string Evenement
            get { return Record.Evenement; }
            set { Record.Evenement = value; }

    public int Create() {
   // Creating table EvePartRecord
   SchemaBuilder.CreateTable("EvePartRecord", table => table
    .Column("Evenement", DbType.String)
    .Column("Date", DbType.DateTime)

Feb 11, 2012 at 12:42 PM

Make your DateTime in the Model nullable:

public virtual DateTime? Date { get; set; } 

Feb 11, 2012 at 7:51 PM

thank you ... this is weird but it did the job?
Is this an Orchard issue or SqlCE or .... ?! 
Somewhen I might have time to dig deeper , ed

Feb 11, 2012 at 11:59 PM

What do you mean "issue"? If you want a nullable date, you need to specify it. Sounds perfectly normal to me.

Feb 12, 2012 at 7:47 AM

my aplogies to accuse Orchard; .. I just didn't even know that there can a ? be used to make it nullable!?, ed


Nov 18, 2013 at 6:43 AM
Edited Nov 18, 2013 at 7:26 AM
I got the same issue and I have also entered '?' sign to make it nullable. But after I enter date from admin side it gives red color message that it is not valid format for Date time. I have entered "'18/11/2013 12:10:00 PM" . I just want to know what kind of format Orchard is following and if I do not enter any date in DateTime field, it works fine.