473,320 Members | 1,896 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,320 software developers and data experts.

simple format question

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
15 1366
"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
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
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

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
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
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
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
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
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
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
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

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

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

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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
15
by: Richard Hollenbeck | last post by:
For example, one college course has only 24 students in it, but the following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs. When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
8
by: Tony | last post by:
Hello I am learning C# and encountered the following problem when I tried to figure out how to print the string {0} in a Console window The following piece of codes complied OK. But when I...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
10
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when...
1
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to...
50
by: Doug | last post by:
I can't imagine this is that hard but I'm sure having a struggle finding it. How do I convert a value like "111403" do a DateTime variable in DotNet (i.e. 11/14/2003)?
7
by: Steven D'Aprano | last post by:
I have a sinking feeling I'm missing something really, really simple. I'm looking for a format string similar to '%.3f' except that trailing zeroes are not included. To give some examples: ...
7
by: JamesG | last post by:
Hi, I need to convert the current time to the format "hh:mm:ss" and date to the format "yyyy-MM-dd". The result of both conversions needs to be of System.DateTime format. I've tried using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.