2

I have a VB 6 source code, and I am rewriting it in .NET At some places I have found a date is converted into "mmddhhnn" format. I am not sure what is "nn" here, also if I put as it is in .NET, then it doesn't convert nn into anything rather it remain "nn" only. What is its equivalent in .NET?

1
  • 2
    I would suggest taking an approach of finding out what your current code does, before trying to port it. The question of what "nn" means in VB6 has nothing to do with .NET. Decouple the "understanding current code" from "migrating to new code" parts. (It looks like Oded has your answer in this case, but you should think about this as a general approach. You can't tell whether or not a migration is successful if you don't know what the code is meant to do.)
    – Jon Skeet
    Commented Apr 29, 2013 at 9:31

2 Answers 2

6

The .NET equivalent is:

MMddHHmm

See VB6 format strings for dates and times and those for .NET.

4
  • 1
    +1 And here is a link to the relevant official VB6 manual topic on MSDN
    – MarkJ
    Commented Apr 29, 2013 at 12:22
  • @MarkJ - That's a nice link, but it is a VBA reference, not VB6.
    – Oded
    Commented Apr 29, 2013 at 12:23
  • True enough, but it seems to be the only relevant documentation on MSDN & it's linked from the "See also" in the VB6 topic on Format.
    – MarkJ
    Commented Apr 29, 2013 at 12:26
  • 1
    @MarkJ - Heh. How... interesting of Microsoft to do that.
    – Oded
    Commented Apr 29, 2013 at 12:27
3

According to this site nn means minutes with leading zero.

So this should be equivalent:

Dim dateString = date.ToString("MMddHHmm")

Uppercase MM means months and lowercase minutes. Uppercase HH means hours in 24 hours, lowercase using a 12-hour

MSDN: Custom Date and Time Format Strings in .NET

2
  • The joys of multiple date/time formats in Microsoft products! ;o)
    – user1945782
    Commented Apr 30, 2013 at 12:12
  • @Westie: Don't associate VB6 with joy ;-) Commented Apr 30, 2013 at 12:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.