469,612 Members | 1,620 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

convert a String to a Date

what's the preferred method in vb.net to convert a String to a Date .... ?
Nov 20 '05 #1
6 8720
Preferred, I don't know.

CType(string, date)

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl...
what's the preferred method in vb.net to convert a String to a Date .... ?

Nov 20 '05 #2
> CType(string, date)

datevar = CDate(string) is shorter. You can also use Date.Parse or Date.ParseExact which can be used to parse a string in a specific format.

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Nov 20 '05 #3
* "John A Grandy" <johnagrandy-at-yahoo-dot-com> scripsit:
what's the preferred method in vb.net to convert a String to a Date .... ?


'DateTime.ParseExact'/'DateTime.Parse'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Cor
I prefer datevar = CDate(string)

Cor
Nov 20 '05 #5
* "Cor" <no*@non.com> scripsit:
I prefer datevar = CDate(string)


;-) -- I hate that...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
CDate is a holdover from VB 6.0. Many developers like to steer clear of
these functions because they cause more overhead than if the .NET equivalent
class is used.
"Eduardo A. Morcillo [MS MVP]" <emorcilloATmvps.org> wrote in message
news:Oc**************@tk2msftngp13.phx.gbl...
CType(string, date)


datevar = CDate(string) is shorter. You can also use Date.Parse or
Date.ParseExact which can be used to parse a string in a specific format.

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Hector A | last post: by
2 posts views Thread by Franck | last post: by
12 posts views Thread by DC Gringo | last post: by
4 posts views Thread by perryclisbee via AccessMonster.com | last post: by
6 posts views Thread by vunet.us | last post: by
8 posts views Thread by deepak_kamath_n | last post: by
4 posts views Thread by Ashraf Ansari | last post: by
4 posts views Thread by =?Utf-8?B?YW5kcmV3?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.