Cultures & dates

J

Jon

I have an asp.net app that I've localized using satellite assemblies. It
works wonderfully, even for displaying dates. My problem comes when I try
to use one of those dates in a SQL query.

I have an SQL like "SELECT * FROM Table WHERE date < @Date"
I make a parameter for it as type SQLDBType.DateTime. This works great for
US dates (12/31/04, for instance). But, the equivalent Frnech date
(31/12/04) throws an excption with the following error: "String was not
recognized as a valid DateTime."
So, I need to know how to convert the french date back to US format so the
SQL server doesn't puke. I'm sure there's a simple way to accomplish this,
but so far it's eluding me.
 
J

Jon

I had been using it all along, but for something different...
set the thread culture and execute the following and it will put it back to
US format....
Dim a As Date = DateTime.Parse(Me.txtDateTo.Text)
 
K

Kevin Spencer

Hmm, cultured Dates. I'd steer clear. They might be "bad" dates. Remember
"Raiders of the Lost Ark?' Hmmm?

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top