DateTime Problems

  • Thread starter Thread starter rn5a
  • Start date Start date
Mark said:
How do you know...?

Because I have accuired knowledge about the ISO 8601 format. Also, I
live in one of the few countries in the world that is actually using the
international standard for date format as the standard date format, so I
am very used to reading dates in this format.
 
Mark said:
But that's the whole point - you can't be sure with this notation...

Yes, you can. Unless you invent your own date format, there is no way
that you can interpret it any other way.
The fact that your code uses one particular format is neither here nor
there... The issue here is the word "inserted" i.e. typed in by a user...

But it's not typed in by a user at all. It's created by converting the
DateTime.Now value into a string.
Just because 2007-08-03 means 3rd August 2007 to you, doesn't imply that it
means the same to somebody else...

Either they know the date format so that they know what it means, or
they don't so it doesn't mean anything at all.
The only 100% guaranteed unambiguous method of date entry where users are
involved is to force three digit months and four digit years...

Not at all. There are many ways of entering a date. But the question is
still not about user input, it's about date formats.
 
Alexey said:
Maybe

.Parameters.AddWithValue("?", Format(DateTime.Now, "yyyy-MM-dd"))

will work?

Perhaps. But it's better to let the database driver handle the date
instead of trying to create a string in a format that it will understand.
 
Because I have accuired knowledge about the ISO 8601 format.

Just like all your users, no doubt...?
Also, I live in one of the few countries in the world that is actually
using the international standard for date format as the standard date
format, so I am very used to reading dates in this format.

So, your apps can be used reliably only by people who have your level of
knowledge of ISO standards, and who have the good fortune to live in the
same country as you...?

It's a big old world, you know... :-)
 
Mark said:
Just like all your users, no doubt...?


So, your apps can be used reliably only by people who have your level of
knowledge of ISO standards, and who have the good fortune to live in the
same country as you...?

It's a big old world, you know... :-)

This is not a discussion of user input, but of date formats. The data in
this case does not come from user input.

If you want to discuss user input, that is a completely different
business. Then the ISO 8601 format is of course only useful in countries
where people use that format.

Sometimes entering a date as a formatted string isn't even an option,
but other methods to select a date has to be used.
 
Back
Top