473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

39th month? Odd DateTime behaviour!

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
Nov 19 '05 #1
5 1042
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

Nov 19 '05 #2
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

Nov 19 '05 #3
"dhnriverside" <da*@musoswire.com> wrote in message
news:F3**********************************@microsof t.com...
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
Nov 19 '05 #4

"dhnriverside" <da*@musoswire.com> wrote in message
news:F3**********************************@microsof t.com...
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

Nov 19 '05 #5
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" <da*@musoswire.com> wrote in message
news:F3**********************************@microsof t.com...
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

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
2
by: Sasidhar Parvatham | last post by:
Hello All, Is there a way I can get dates for first and last fridays of a month? Any suggestion would be helpful. Thanks.
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
34
by: prosoft | last post by:
When I use Dim myDTFI As DateTimeFormatInfo = New CultureInfo("he-IL", True).DateTimeFormat Dim strhmon1 As String = (myDTFI.GetMonthName(hmon1)) MsgBox(strhmon1) I get the local name of the...
5
by: PAPutzback | last post by:
txtToDate.Text = (Now.Date.AddDays(-(Now.Day)).AddMonths(1))
4
by: gabor | last post by:
hi, i'm trying to get the date of the day one month ago. for example: today = 12.apr.2006 one-month-ago = 12.mar.2006 so:
6
by: Zeba | last post by:
Hi, I have a page with a calendar and two datalist items - one containing month values and the other, year values. Depending on the month/year value chosen ( in text/string format ) I should be...
19
by: edfialk | last post by:
Hi, does anyone happen to know of a script that would return the number of seconds in a month if I give it a month and a year? My python is a little weak, but if anyone could offer some...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.