cdate

C

cj2

why do you suppose the default date format for cdate() is mm/dd/yyyy? I
always felt the correct/default way of writing dates worldwide, for
computers at least, was yyyymmdd as this way they sort into
chronological order.
 
C

Cor Ligthert[MVP]

CJ

There is no default format for date and/or time.

What you show is an ISO date used in countries like Sweden, China and more
(mostly those who are using the arabian cifers after 1900).

What is in your computer is the USA format (only used there and in some Coca
Cola cultures)

Another major format most is where West Europe languages are ised. including
English with the exception of the USA, that is dd-mm-yy, this can with
slashes as well.

This can be set however in every modern Microsoft OS computer in the Culture
settings

Cor
 
C

Colbert Zhou [MSFT]

Hello Chris,

Another approach, if we want to create a date from a string which does not
depend on the system setting, we can also try the .NET function
DateTime.Parse(String, IFormatProvider). We can specify the culture in the
second parameter. You can get an example from the following MSDN document,
http://msdn.microsoft.com/en-us/library/kc8s65zs.aspx

If you have any other questions, please let me know. Have a nice day!


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
 
C

Cor Ligthert[MVP]

Hello Colbert,

Chris has asked this in a message somewhat earlier, he got a lot of correct
replies with all kind of correct methods to do that.

:)

Be aware that the IFormatProvider in this case for VB simple can be replaced
by Nothing, while the parseexact and tryparseexat are for as cj stated it
definitly better.

Cor
 
P

Phill W.

cj2 said:
why do you suppose the default date format for cdate() is mm/dd/yyyy?

IMHO, it's simply because most of the software we use is written by
Americans, or is written with the American market in mind.
In either case, the above would be the de facto, "default" date format.
I always felt the correct/default way of writing dates worldwide, for
computers at least, was yyyymmdd as this way they sort into
chronological order.

Again IMHO, "yyyyMMdd" /isn't/ a date; it's an eight digit number that
could mean anything. However, I may be in the minority on this one; the
international standard bodies seem to agree with you, which is why ISO
8601 defines numerous date and/or time formats, all along the lines of...

yyyy-MM-dd HH:mm:ss

.... and /even/, where the need for compactness overrides that of
readability, even ....

yyyyMMdd

HTH,
Phill W.
 
C

Cor Ligthert[MVP]

Phill,

IMHO, it's simply because most of the software we use is written by
Americans, or is written with the American market in mind.
In either case, the above would be the de facto, "default" date format.
It is not.

The DateTime is a Int64 that contains 100-nano ticks which start to count on
the virtual 01-01-01.

I write virtual because almost all countries in the world (including China)
use the Gregorian calendar. This calendar did not start in every country in
the same year. The UK and his colonies were from the European cultures one
of the latest at around 1753.

What you see in VB as showed in the debugger and other places is the
DateTime literal, which uses the USA format.

This is for years a problem in VB and not in C# where DateTimes are nicely
showed in the culture setting from the computer.

Cor
 
C

cj2

Interesting to see what people say. People have always formatted dates
differently in different countries, but from say 15 or 20 years ago I
was always under the impression that computers should deal with dates
YYYYMMDD. The reason given most often back then was they sorted
correctly that way. Keep in mind for the most part this was not a date
type variable it was, as someone mentioned, an 8 digit number. But it
stored dates and stored them in a way that sorted. I guess in this
world with many date time variables etc that reason is no longer valid.

After my recent formatting dates investigation got me thinking about it
I just wanted to see what others though along these lines.

Thanks for the input everyone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top