Cor,
It seems to me you have the blinders on a just a little too tight. :-|
In other words you are only seeing CDate, where as you might want to look to
the side & see DateTime.ParseExact also!
I agree using the VB Convert Functions in most cases is the way to go.
However like any rule there are exceptions. As has been demonstrated,
converting a DateTime with a specific format is one of those exceptions.
An analogy might be a Carpenter. Does a (good) carpenter have a single
hammer? No, they have 2 or 3 kinds of hammers, as each is needed depending
on what he is doing. Does he have a single screwdriver? No, he has standard
(or slotted) and Phillips, plus possible a whole slew of others. Does he
have a single size of screwdriver? No he has #0 thru #4 sizes based on the
requirements of the specific job.
The Carpenter has different tools & sizes & shapes of the "same" tool, as
each is required for a specific job. Same with CDate & DateTime.ParseExact.
Most of the time CDate (a #2 slotted screwdriver) is fine, however sometimes
you need a specialized tool, such as DateTime.ParseExact (a #0 slotted
screwdriver).
For the life of me, I really don't understand why you don't see this.
Reading Reny & z.'s earlier question both stated, in a specific format,
which to a number of developers myself included, suggests that
DateTime.ParseExact with a specific format string is the correct method in
this instance.
I hope you realize I am not saying don't use CDate, as I use it where CDate
makes sense.
What I am saying is that CDate does not make sense in this case. For some
reason you are not accepting this, from Herfried, Jon, myself or others. I
really don't know why, or how we can better explain it.
In closing, I sincerely hope you will take the time & reread both of these
threads and make a concerted effort to understand why a number of us may be
saying that in these two specific cases using DateTime.ParseExact might be
better then relying solely on CDate. Hopefully you will realize that the
blinders are just a little too tight.
Hope this helps
Jay
Cor Ligthert said:
Jay,
I just following the advice from the VBNet pages to use the Convert
Functions from which I understand it is advices to use them because they
give the best overall performance.
Although when those advices were not given do I find them very clear to
use and easy. I find them one of the best extra parts of VBNet.
Because of all that doing, from Herfried and others who say that when
someone who asks how to set a date and time, and than gives with that a
format string, particulary wants to use change a format not in his own
local format I give now that other situation.
In my opinion are those datestring information more given as extra
information for us (what format the OP is using) than that he directly
wants to convert the format. I did not by accident give the Australian
format when I saw the time of the message. However that was a gues.
Beside that can I only think of one situation where it is needed to change
the dateandtime given in a culture and that is with a webformpage or with
any other document where that is in.
Than it is better in my opinion to set in the class that processes that
first the right language/culture and set that back at the end of the
class. Doing that for every instruction inside will give in my idea more
dangerous code when there is maintanance.
That has nothing to do with understanding. Sometimes I get the idea that
you think that I write things because of lack of knowledge.
For me are rules as 80/20 and "keep it simple" very important. A program
have to be made however mostly as well will there be maintenance on it.
I hope that you can share my opinion above and understand why I am telling
this about globalization.
Cor
<<snip>>