Stack Overflow is hard

I tried. Not with as much effort as I could muster, but I really tried. I can’t answer a single question at Stack Overflow!

There was this one where I could answer, and someone already gave the answer I’d give (if I did write a reply). So I decided to vote that answer up instead. Not enough reputation to do it.

To earn reputation at the beginning, I’m practically left with two options: ask a question or answer a question. We’ve already established that I’m incapable of answering any of them. I looked at the questions tagged with C# and sql. Maybe I didn’t look hard enough…

Anyway, I didn’t want to ask a question for the sake of getting reputation. If I’m asking one, it better be because it’s bugging me. And I eventually asked one.

It’s something to do with the Month function in Visual Basic. The code I’m maintaining mixes traditional Visual Basic code with VB.NET code in an ASP.NET web application. On the web server, Month("10/01/2008") returns 10 (October). On developers’ machines, it returns 1 (January). Note that a string is passed as a parameter instead of a date.

I created a test web application with a similar setup and deployed it on that server and … I got 1. Aarrgghh! For some reason, I’m unable to replicate that behaviour.

My best guess is that some setting on the server specific to that web application is set, and I don’t know where. The machine.config? The web.config? Some IIS setting?

If I added this to the globalization tag in the web.config file on my machine:
culture="en-US" uiCulture="en-US"
I am able to replicate the return of 10. But the server’s web.config doesn’t have those attributes in its globalization tag.

I can solve the problem by forcibly using DateTime.ParseExact() with “dd/MM/yyyy” format all over the place. I just want to know why the Month() function is inconsistent. If you know, please tell me your answer. I’d appreciate it very much. Send your answer in a comment, or visit the Stack Overflow’s question page for it. Thank you.

Comments

  1. if you think an answer is good, accept it. This gives you 2 reputation points more ;)

  2. Vincent Tan says:

    Thanks ugasoft, I’ll keep that in mind!

    And someone voted that question up a little. I’ve got 31 reputation last I check. Thanks to whoever voted. Now perhaps I can go do something more useful on the site.