39th month? Odd DateTime behaviour!

Discussion in 'ASP .Net' started by =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 2, 2005.

  1. Hi guys - Mars bars at the ready here...

    Got the following 2 lines of code...

    DateTime rightnow = DateTime.Now;
    string ReportDate = rightnow.ToString("yyyy-mm-dd");

    Fine?

    Well, it's giving me a date just now of "2005-39-02" !!!! how!!?

    Cheers


    Dan
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 2, 2005
    #1
    1. Advertising

  2. you sure you aren't using MM instead of mm (Minutes instead of Month)??

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "dhnriverside" wrote:

    > Hi guys - Mars bars at the ready here...
    >
    > Got the following 2 lines of code...
    >
    > DateTime rightnow = DateTime.Now;
    > string ReportDate = rightnow.ToString("yyyy-mm-dd");
    >
    > Fine?
    >
    > Well, it's giving me a date just now of "2005-39-02" !!!! how!!?
    >
    > Cheers
    >
    >
    > Dan
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Sep 2, 2005
    #2
    1. Advertising

  3. Try using MM for month in the string format. You are getting minutes.

    "dhnriverside" wrote:

    > Hi guys - Mars bars at the ready here...
    >
    > Got the following 2 lines of code...
    >
    > DateTime rightnow = DateTime.Now;
    > string ReportDate = rightnow.ToString("yyyy-mm-dd");
    >
    > Fine?
    >
    > Well, it's giving me a date just now of "2005-39-02" !!!! how!!?
    >
    > Cheers
    >
    >
    > Dan
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=, Sep 2, 2005
    #3
  4. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Oliver Wong Guest

    "dhnriverside" <> wrote in message
    news:...
    > Got the following 2 lines of code...
    >
    > DateTime rightnow = DateTime.Now;
    > string ReportDate = rightnow.ToString("yyyy-mm-dd");
    >
    > Well, it's giving me a date just now of "2005-39-02" !!!! how!!?


    Try constructing a DateTime object with a specific timestamp to
    reproduce the problem (hint: check what time your system clock is
    reporting).

    Post a short, self-contained, compilable piece of code so that we can
    reproduce the bug.

    - Oliver
    Oliver Wong, Sep 2, 2005
    #4
  5. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Mythran Guest

    "dhnriverside" <> wrote in message
    news:...
    > Hi guys - Mars bars at the ready here...
    >
    > Got the following 2 lines of code...
    >
    > DateTime rightnow = DateTime.Now;
    > string ReportDate = rightnow.ToString("yyyy-mm-dd");
    >
    > Fine?
    >
    > Well, it's giving me a date just now of "2005-39-02" !!!! how!!?
    >
    > Cheers
    >
    >
    > Dan


    lol "4-digit year dash 2-digit minute dash two-digit day" :)

    rightnow.ToString("yyyy-MM-dd");

    Mythran
    Mythran, Sep 2, 2005
    #5
  6. oops :p

    thanks guys, it was the wrong case on the "MM" - bit daft though, year and
    day are lowercase, and month is uppercase!! whats with that? surely more
    sense would be to make HH:MM and dd/mm/yy - weird!

    Sorted anyway - cheers!

    "Mythran" wrote:

    >
    > "dhnriverside" <> wrote in message
    > news:...
    > > Hi guys - Mars bars at the ready here...
    > >
    > > Got the following 2 lines of code...
    > >
    > > DateTime rightnow = DateTime.Now;
    > > string ReportDate = rightnow.ToString("yyyy-mm-dd");
    > >
    > > Fine?
    > >
    > > Well, it's giving me a date just now of "2005-39-02" !!!! how!!?
    > >
    > > Cheers
    > >
    > >
    > > Dan

    >
    > lol "4-digit year dash 2-digit minute dash two-digit day" :)
    >
    > rightnow.ToString("yyyy-MM-dd");
    >
    > Mythran
    >
    >
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 3, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    704
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    532
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    386
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    333
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    754
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page