By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Date conversion

P: n/a
My regional setting is "yy-MM-dd" for the date

But for my application I have to use the format date "dd/MM/yyyy"
I convert the date to dd/MM/yyyy with this code :

m_curSel.ToString("dd/MM/yyyy")

But I have error : "Cast of the string "23-12-2004" in type Date is non
valide"

WHY ?

Another question : it's possible to use date variable independing of
the regional setting of the PC

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"bnob" <bn**@bluewin.ch> schrieb:
My regional setting is "yy-MM-dd" for the date

But for my application I have to use the format date "dd/MM/yyyy"
I convert the date to dd/MM/yyyy with this code :

m_curSel.ToString("dd/MM/yyyy")
Is 'm_curSel' a 'Date' variable?

Your code works fine for me. If you want to use the "/" character as
separator:

\\\
MsgBox(Date.Now.ToString("dd\/MM\/yyyy"))
///
But I have error : "Cast of the string "23-12-2004" in type Date is non
valide"
I don't see where you cast a string into a date. Your code is converting a
date to a string, I assume. You can use 'DateTime.ParseExact' to convert a
date string that is in a specific format into a date.
Another question : it's possible to use date variable independing of the
regional setting of the PC


'Date' is independent from regional settings. Both, 'DateTime.ParseExact'
and 'DateTime.ToString' can be used to parse/output date strings by
specifying a certain date format string.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
Bnob,

In addition to Herfried (how is it possible about dates).

Your email adres is in Swiss, so you make me curious. I have always seen
there dates as "dd-MM-yyyy" is that changed the last months?

However when your culture setting is still the as the rest from Europe, than
you can use to make it culture independent by using

dim mystring as string = date.now.tostring("d")

I hope this helps

Cor

"bnob" <bn**@bluewin.ch>

But for my application I have to use the format date "dd/MM/yyyy"
I convert the date to dd/MM/yyyy with this code :

m_curSel.ToString("dd/MM/yyyy")

But I have error : "Cast of the string "23-12-2004" in type Date is non
valide"

WHY ?

Another question : it's possible to use date variable independing of the
regional setting of the PC

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.