System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.' Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How can i fix this kind of exception? ArgumentOutOfRangeExceptionDateTime constructor throws error when the values are OKAn un-representable DateTime for year, Month and Day parameters in C#How do I map an Oracle timestamp to a DateTime in Fluent NHibernate?Year, Month, and Day parameters describe an un-representable DateTime in Persian calenderhow to fix un-representable DateTime in C#how to Pass data from dropdownlist to databaseGenerate Date Time offsetDateTime month 0 invalid formatValidation error when numeric 2 is entered in the show up down month

What ability score does a Hexblade's Pact Weapon use for attack and damage when wielded by another character?

How long after the last departure shall the airport stay open for an emergency return?

Protagonist's race is hidden - should I reveal it?

c++ diamond problem - How to call base method only once

Map material from china not allowed to leave the country

How to translate "red flag" into Spanish?

How to open locks without disable device?

Could moose/elk survive in the Amazon forest?

Is a 5 watt UHF/VHF handheld considered QRP?

Implementing 3DES algorithm in Java: is my code secure?

Co-worker works way more than he should

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

Why does the Cisco show run command not show the full version, while the show version command does?

Justification for leaving new position after a short time

std::is_constructible on incomplete types

How would I use different systems of magic when they are capable of the same effects?

Retract an already submitted recommendation letter (written for an undergrad student)

Has a Nobel Peace laureate ever been accused of war crimes?

Could Neutrino technically as side-effect, incentivize centralization of the bitcoin network?

All ASCII characters with a given bit count

Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?

Second order approximation of the loss function (Deep learning book, 7.33)

Check if a string is entirely made of the same substring

Are these square matrices always diagonalisable?



System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How can i fix this kind of exception? ArgumentOutOfRangeExceptionDateTime constructor throws error when the values are OKAn un-representable DateTime for year, Month and Day parameters in C#How do I map an Oracle timestamp to a DateTime in Fluent NHibernate?Year, Month, and Day parameters describe an un-representable DateTime in Persian calenderhow to fix un-representable DateTime in C#how to Pass data from dropdownlist to databaseGenerate Date Time offsetDateTime month 0 invalid formatValidation error when numeric 2 is entered in the show up down month



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2















Please see the code below:



[TestFixture]
public class UnitTest1

[Test]
public void TestMethod1()

DateTime dob = new DateTime(2001, 02, 29);
DateTime todaysDate = new DateTime(2001, 02, 29);




When I run this code the second line of the method throws an exception: System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'. However, if I comment out the first line of the method it runs successfully. What is the problem?










share|improve this question

















  • 4





    Because February in 2001 did not have 29 days.

    – Brandon
    Feb 5 '18 at 17:54






  • 3





    comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

    – Steve
    Feb 5 '18 at 17:56












  • Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

    – dasblinkenlight
    Feb 5 '18 at 17:57






  • 2





    The test fails in both cases on my side too

    – Martin Zikmund
    Feb 5 '18 at 17:58






  • 1





    What test framework are you using? Are you sure it runs the test when you comment out the first line?

    – DavidG
    Feb 5 '18 at 18:06

















-2















Please see the code below:



[TestFixture]
public class UnitTest1

[Test]
public void TestMethod1()

DateTime dob = new DateTime(2001, 02, 29);
DateTime todaysDate = new DateTime(2001, 02, 29);




When I run this code the second line of the method throws an exception: System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'. However, if I comment out the first line of the method it runs successfully. What is the problem?










share|improve this question

















  • 4





    Because February in 2001 did not have 29 days.

    – Brandon
    Feb 5 '18 at 17:54






  • 3





    comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

    – Steve
    Feb 5 '18 at 17:56












  • Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

    – dasblinkenlight
    Feb 5 '18 at 17:57






  • 2





    The test fails in both cases on my side too

    – Martin Zikmund
    Feb 5 '18 at 17:58






  • 1





    What test framework are you using? Are you sure it runs the test when you comment out the first line?

    – DavidG
    Feb 5 '18 at 18:06













-2












-2








-2


0






Please see the code below:



[TestFixture]
public class UnitTest1

[Test]
public void TestMethod1()

DateTime dob = new DateTime(2001, 02, 29);
DateTime todaysDate = new DateTime(2001, 02, 29);




When I run this code the second line of the method throws an exception: System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'. However, if I comment out the first line of the method it runs successfully. What is the problem?










share|improve this question














Please see the code below:



[TestFixture]
public class UnitTest1

[Test]
public void TestMethod1()

DateTime dob = new DateTime(2001, 02, 29);
DateTime todaysDate = new DateTime(2001, 02, 29);




When I run this code the second line of the method throws an exception: System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'. However, if I comment out the first line of the method it runs successfully. What is the problem?







c#






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 5 '18 at 17:53









w0051977w0051977

5,9981379183




5,9981379183







  • 4





    Because February in 2001 did not have 29 days.

    – Brandon
    Feb 5 '18 at 17:54






  • 3





    comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

    – Steve
    Feb 5 '18 at 17:56












  • Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

    – dasblinkenlight
    Feb 5 '18 at 17:57






  • 2





    The test fails in both cases on my side too

    – Martin Zikmund
    Feb 5 '18 at 17:58






  • 1





    What test framework are you using? Are you sure it runs the test when you comment out the first line?

    – DavidG
    Feb 5 '18 at 18:06












  • 4





    Because February in 2001 did not have 29 days.

    – Brandon
    Feb 5 '18 at 17:54






  • 3





    comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

    – Steve
    Feb 5 '18 at 17:56












  • Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

    – dasblinkenlight
    Feb 5 '18 at 17:57






  • 2





    The test fails in both cases on my side too

    – Martin Zikmund
    Feb 5 '18 at 17:58






  • 1





    What test framework are you using? Are you sure it runs the test when you comment out the first line?

    – DavidG
    Feb 5 '18 at 18:06







4




4





Because February in 2001 did not have 29 days.

– Brandon
Feb 5 '18 at 17:54





Because February in 2001 did not have 29 days.

– Brandon
Feb 5 '18 at 17:54




3




3





comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

– Steve
Feb 5 '18 at 17:56






comment out the first line still breaks on my machine. unless you meant [TestFixture] which might just skip the Test depending on what [TestFixture] is.

– Steve
Feb 5 '18 at 17:56














Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

– dasblinkenlight
Feb 5 '18 at 17:57





Good chances are you see an exception on the wrong line. Try adding some code between the first and second line (say, a nice little for loop that does nothing for a few iterations), and see what would happen.

– dasblinkenlight
Feb 5 '18 at 17:57




2




2





The test fails in both cases on my side too

– Martin Zikmund
Feb 5 '18 at 17:58





The test fails in both cases on my side too

– Martin Zikmund
Feb 5 '18 at 17:58




1




1





What test framework are you using? Are you sure it runs the test when you comment out the first line?

– DavidG
Feb 5 '18 at 18:06





What test framework are you using? Are you sure it runs the test when you comment out the first line?

– DavidG
Feb 5 '18 at 18:06












2 Answers
2






active

oldest

votes


















6














Because in 2001 February had only 28 days not 29 :-)






share|improve this answer


















  • 2





    Why does the first line run then (when there are two lines).

    – w0051977
    Feb 5 '18 at 17:55






  • 1





    Oh my! I didn't notice that!

    – Martin Zikmund
    Feb 5 '18 at 17:55


















0














In case you stumble across this post with a similar confusion about dates - I have found that if you have two date assignments one after the other, and the first one has a problem, the exception may be thrown on the second one (which doesn't have a problem).



See my screenshot below - the first line is bad, but the exception is thrown on the second line.



enter image description here






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48628587%2fsystem-argumentoutofrangeexception-year-month-and-day-parameters-describe-an%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    Because in 2001 February had only 28 days not 29 :-)






    share|improve this answer


















    • 2





      Why does the first line run then (when there are two lines).

      – w0051977
      Feb 5 '18 at 17:55






    • 1





      Oh my! I didn't notice that!

      – Martin Zikmund
      Feb 5 '18 at 17:55















    6














    Because in 2001 February had only 28 days not 29 :-)






    share|improve this answer


















    • 2





      Why does the first line run then (when there are two lines).

      – w0051977
      Feb 5 '18 at 17:55






    • 1





      Oh my! I didn't notice that!

      – Martin Zikmund
      Feb 5 '18 at 17:55













    6












    6








    6







    Because in 2001 February had only 28 days not 29 :-)






    share|improve this answer













    Because in 2001 February had only 28 days not 29 :-)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 5 '18 at 17:54









    Martin ZikmundMartin Zikmund

    26.4k63964




    26.4k63964







    • 2





      Why does the first line run then (when there are two lines).

      – w0051977
      Feb 5 '18 at 17:55






    • 1





      Oh my! I didn't notice that!

      – Martin Zikmund
      Feb 5 '18 at 17:55












    • 2





      Why does the first line run then (when there are two lines).

      – w0051977
      Feb 5 '18 at 17:55






    • 1





      Oh my! I didn't notice that!

      – Martin Zikmund
      Feb 5 '18 at 17:55







    2




    2





    Why does the first line run then (when there are two lines).

    – w0051977
    Feb 5 '18 at 17:55





    Why does the first line run then (when there are two lines).

    – w0051977
    Feb 5 '18 at 17:55




    1




    1





    Oh my! I didn't notice that!

    – Martin Zikmund
    Feb 5 '18 at 17:55





    Oh my! I didn't notice that!

    – Martin Zikmund
    Feb 5 '18 at 17:55













    0














    In case you stumble across this post with a similar confusion about dates - I have found that if you have two date assignments one after the other, and the first one has a problem, the exception may be thrown on the second one (which doesn't have a problem).



    See my screenshot below - the first line is bad, but the exception is thrown on the second line.



    enter image description here






    share|improve this answer



























      0














      In case you stumble across this post with a similar confusion about dates - I have found that if you have two date assignments one after the other, and the first one has a problem, the exception may be thrown on the second one (which doesn't have a problem).



      See my screenshot below - the first line is bad, but the exception is thrown on the second line.



      enter image description here






      share|improve this answer

























        0












        0








        0







        In case you stumble across this post with a similar confusion about dates - I have found that if you have two date assignments one after the other, and the first one has a problem, the exception may be thrown on the second one (which doesn't have a problem).



        See my screenshot below - the first line is bad, but the exception is thrown on the second line.



        enter image description here






        share|improve this answer













        In case you stumble across this post with a similar confusion about dates - I have found that if you have two date assignments one after the other, and the first one has a problem, the exception may be thrown on the second one (which doesn't have a problem).



        See my screenshot below - the first line is bad, but the exception is thrown on the second line.



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 6:33









        Michael RodriguesMichael Rodrigues

        4,45722147




        4,45722147



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48628587%2fsystem-argumentoutofrangeexception-year-month-and-day-parameters-describe-an%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко