Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 39th month? Odd DateTime behaviour!

Reply
Thread Tools

39th month? Odd DateTime behaviour!

 
 
=?Utf-8?B?ZGhucml2ZXJzaWRl?=
Guest
Posts: n/a
 
      09-02-2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q3VydF9DIFtNVlBd?=
Guest
Posts: n/a
 
      09-02-2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJhZCBSb2JlcnRz?=
Guest
Posts: n/a
 
      09-02-2005
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

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      09-02-2005
"dhnriverside" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Mythran
Guest
Posts: n/a
 
      09-02-2005

"dhnriverside" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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

 
Reply With Quote
 
=?Utf-8?B?ZGhucml2ZXJzaWRl?=
Guest
Posts: n/a
 
      09-03-2005
oops

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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments