By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

simple format question

P: n/a
Rob
In order to create a date in CCYY-MM-DD fashion, I used to be able to use
the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax...

This no longer appears to work in vb.net. I know how I could do this...,
by prepending a "0" to the month and taking the right 2 characters, but that
is silly.

What is the new "easy" way ?

Is there a list some where of all the string and date manipulation functions
with "old" and "new" methods somewhere ?

Thanks !
Nov 24 '06 #1
Share this Question
Share on Google+
15 Replies


P: n/a
"Rob" <ro***@yahoo.comwrote in
news:Xs******************************@comcast.com:
In order to create a date in CCYY-MM-DD fashion, I used to be able to
use the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax...

This no longer appears to work in vb.net.
you need cap M's...

format (Now, "yyyy-MM-dd")
Nov 24 '06 #2

P: n/a
MessageBox.Show(Format(DateTime.Now, "yy-MM-dd"))

Newbie Coder
"tony obrien" <tob_@_sourcecode-inc.comwrote in message
news:Xn*********************************@130.81.64 .196...
"Rob" <ro***@yahoo.comwrote in
news:Xs******************************@comcast.com:
In order to create a date in CCYY-MM-DD fashion, I used to be able to
use the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax...

This no longer appears to work in vb.net.


you need cap M's...

format (Now, "yyyy-MM-dd")

Nov 24 '06 #3

P: n/a
There's a list of all the string and date manipulation
functions and how to use them in Francesco Balena's book,
VB2005:The Language. This is an excellent book for lots
of reasons. Great reference.

Another interesting book is "The .Net Languages: A Quick
Translation Guide" by Brian Bischof. This has VB6, VB.Net,
and C#.Net syntax for a bunch of common code, like data types
and operators, exception handling, classes (and all that
involves), events, string management, windows forms, date
and time functions, match and financial calcs, collections,
etc. I have found it very helpful.

The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)

Robin S.
------------------------------------
"Rob" <ro***@yahoo.comwrote in message
news:Xs******************************@comcast.com. ..
In order to create a date in CCYY-MM-DD fashion, I used to be able to use
the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax...

This no longer appears to work in vb.net. I know how I could do this...,
by prepending a "0" to the month and taking the right 2 characters, but
that is silly.

What is the new "easy" way ?

Is there a list some where of all the string and date manipulation
functions with "old" and "new" methods somewhere ?

Thanks !

Nov 24 '06 #4

P: n/a

RobinS wrote:
There's a list of all the string and date manipulation
<snip>
The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)
Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...

--
Tom Shelton

Nov 25 '06 #5

P: n/a
Tom,

I don't like those C# evangelists in this newsgroup.

:-)

Are you a newbie wanting a war?

:-)

Cor

"Tom Shelton" <to*********@comcast.netschreef in bericht
news:11**********************@45g2000cws.googlegro ups.com...
>
RobinS wrote:
>There's a list of all the string and date manipulation

<snip>
>The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)

Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...

--
Tom Shelton

Nov 25 '06 #6

P: n/a
Rob,

The DateTime.ToString(IDateTimeprovider) gives you endless possibilities.

http://msdn2.microsoft.com/en-us/library/ht77y576.aspx

http://msdn2.microsoft.com/en-us/library/az4se3k1.aspx

(They are already for years in the category most bad pages on MSDN).

Beside that you can use the DateTime.ParseExact if you really have strange
wishes.
Be aware that that one makes your datetime representation direct local to a
situation.

Dates and times are very different written, by instance the USA, English
Canada and French Canada have all three diferent notations of that.

Cor

"Rob" <ro***@yahoo.comschreef in bericht
news:Xs******************************@comcast.com. ..
In order to create a date in CCYY-MM-DD fashion, I used to be able to use
the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax...

This no longer appears to work in vb.net. I know how I could do this...,
by prepending a "0" to the month and taking the right 2 characters, but
that is silly.

What is the new "easy" way ?

Is there a list some where of all the string and date manipulation
functions with "old" and "new" methods somewhere ?

Thanks !

Nov 25 '06 #7

P: n/a
I like to program in VB. I find there's too much whitespace
in C# -- all those blank lines with nothing but parentheses
or curly brackets. I think VB's "Implements IBindingList"
is a lot clearer than "sub name : IBindingList". As a VB
programmer, I had no idea what that meant the first time
I saw it! Sometimes being more verbose is better for
readability and long-term maintainability.

And I don't get the thing about checking against Null.
Null, Nothing, it's only 3 more characters, so what's
the diff?

But everyone is different, and it's probably what you're
used to that makes the most sense to you. So I celebrate
your right to enjoy C# more than VB, while retaining mine
to do the opposite! (Put your boots on! It's getting deep
in here!)

Robin S.
------------------
"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
>
RobinS wrote:
>There's a list of all the string and date manipulation

<snip>
>The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)

Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...

--
Tom Shelton

Nov 25 '06 #8

P: n/a
Oh my!

VB.NET vs C# is a debate that is never going to have an end!

Let us distill it to one simple maxim?

Which language do you prefer? That one's the best

On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <to*********@comcast.net>
wrote:
>
RobinS wrote:
>There's a list of all the string and date manipulation

<snip>
>The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)

Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 25 '06 #9

P: n/a
I agree!

Robin S.
-------------------
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:0h********************************@4ax.com...
Oh my!

VB.NET vs C# is a debate that is never going to have an end!

Let us distill it to one simple maxim?

Which language do you prefer? That one's the best

On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <to*********@comcast.net>
wrote:
>>
RobinS wrote:
>>There's a list of all the string and date manipulation

<snip>
>>The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)

Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...
--

Bits.Bytes.
http://bytes.thinkersroom.com

Nov 25 '06 #10

P: n/a
Robin,

I was only tickling Tom, he is one of the longest regulars from the VB.Net
newsgroup.]

For you the casting equivalent in c# is.
DirectCast is in C# x as myType
Ctype is in C# (myType) x

That is so much different makes that I like it more in the VB.Net way, but
just my opinion.

Cor

"RobinS" <Ro****@NoSpam.yah.noneschreef in bericht
news:m5******************************@comcast.com. ..
>I agree!

Robin S.
-------------------
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:0h********************************@4ax.com...
>Oh my!

VB.NET vs C# is a debate that is never going to have an end!

Let us distill it to one simple maxim?

Which language do you prefer? That one's the best

On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <to*********@comcast.net>
wrote:
>>>
RobinS wrote:
There's a list of all the string and date manipulation

<snip>

The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)
Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...
--

Bits.Bytes.
http://bytes.thinkersroom.com


Nov 25 '06 #11

P: n/a
I agree with you about the casting; it's so much clearer in VB.
I bought that data binding book by Brian Noyes, which is in C#,
and it forced me to learn to translate. I had some trouble with
the stuff that's way different, like event handlers, interfaces,
and casting variables.

But I can respect other people's opinions. (Unlike some trolls.)

Robin S.
----------------------------------
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Robin,

I was only tickling Tom, he is one of the longest regulars from the VB.Net
newsgroup.]

For you the casting equivalent in c# is.
DirectCast is in C# x as myType
Ctype is in C# (myType) x

That is so much different makes that I like it more in the VB.Net way, but
just my opinion.

Cor

"RobinS" <Ro****@NoSpam.yah.noneschreef in bericht
news:m5******************************@comcast.com. ..
>>I agree!

Robin S.
-------------------
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:0h********************************@4ax.com.. .
>>Oh my!

VB.NET vs C# is a debate that is never going to have an end!

Let us distill it to one simple maxim?

Which language do you prefer? That one's the best

On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <to*********@comcast.net>
wrote:
RobinS wrote:
There's a list of all the string and date manipulation

<snip>

The only gotcha is that it's probably for .Net 2002. But
I still find it helpful when just looking for syntax diffs
between VB.Net and C#.Net (I can't ever remember how to
cast in C#, or implement interfaces. Sigh.)
>

Really? If anything I think the VB.NET version of both is harder...
In fact, I like the C# as syntax when working with reference types
because you can avoid invalid cast exceptions and simply check for
null.

The VB.NET way of interfaces is way to wordy for my taste - of course
it does have the nice side effect of allowing you to rename the
interface method...
--

Bits.Bytes.
http://bytes.thinkersroom.com



Nov 25 '06 #12

P: n/a

Cor Ligthert [MVP] wrote:
Tom,

I don't like those C# evangelists in this newsgroup.

:-)
Cor, I'm not evangelizing :) I like VB.NET - I just happen to like the
terser syntax of C-style languages. So,

int i = (int) someValue;

makes more sense to me then using"

Dim i As Integer = CType (someValue, Integer)
Are you a newbie wanting a war?

:-)
No wars needed :)

--
Tom Shelton

Nov 26 '06 #13

P: n/a

RobinS wrote:
I like to program in VB. I find there's too much whitespace
in C# -- all those blank lines with nothing but parentheses
or curly brackets. I think VB's "Implements IBindingList"
is a lot clearer than "sub name : IBindingList". As a VB
programmer, I had no idea what that meant the first time
I saw it! Sometimes being more verbose is better for
readability and long-term maintainability.

And I don't get the thing about checking against Null.
Null, Nothing, it's only 3 more characters, so what's
the diff?

But everyone is different, and it's probably what you're
used to that makes the most sense to you. So I celebrate
your right to enjoy C# more than VB, while retaining mine
to do the opposite! (Put your boots on! It's getting deep
in here!)

Robin - I hope you realize that I ment no offense by my comments. I
like VB.NET just fine. I just happen to like C-style languages more.
And yes, I even like case sensitivity (and no, I don't have a good
reason for it :).

You have every right to use the language you enjoy most :)
--
Tom Shelton

Nov 26 '06 #14

P: n/a

Rad [Visual C# MVP] wrote:
Oh my!

VB.NET vs C# is a debate that is never going to have an end!

Let us distill it to one simple maxim?

Which language do you prefer? That one's the best
I agree. I wasn't trying to start a debate. Just a friendly
discussion.

--
Tom Shelton

Nov 26 '06 #15

P: n/a
"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
>
RobinS wrote:
>I like to program in VB. I find there's too much whitespace
in C# -- all those blank lines with nothing but parentheses
or curly brackets. I think VB's "Implements IBindingList"
is a lot clearer than "sub name : IBindingList". As a VB
programmer, I had no idea what that meant the first time
I saw it! Sometimes being more verbose is better for
readability and long-term maintainability.

And I don't get the thing about checking against Null.
Null, Nothing, it's only 3 more characters, so what's
the diff?

But everyone is different, and it's probably what you're
used to that makes the most sense to you. So I celebrate
your right to enjoy C# more than VB, while retaining mine
to do the opposite! (Put your boots on! It's getting deep
in here!)


Robin - I hope you realize that I ment no offense by my comments. I
like VB.NET just fine. I just happen to like C-style languages more.
And yes, I even like case sensitivity (and no, I don't have a good
reason for it :).

You have every right to use the language you enjoy most :)
--
Tom Shelton
Oh, no, I didn't think you meant any offense by your comments.
I thought we were just kind of jibing at each other with humor,
but both respecting the other's opinions and wishes.

Have fun,
Robin S.
Nov 26 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.