By default a
DateTime object will not handle any formatting (such as DD/MM/YYYY etc) as that will be handled depending on how you elect to output it through the .ToString() method as seen below :
'Create a DateTime object'
Dim dt As DateTime = DateTime.Now
'You can use the .ToString() method to handle how you would like to format your Date'
Dim dtString As String = dt.ToString("dd/MM/yyyy")
If you would like more information on how you can format DateTime objects, you can see the following link on handling Custom Date and Time Formatting :
Member
143 Points
423 Posts
HOW TO DECALRE DATE IN VB.NET
May 21, 2013 06:15 AM|zubayba|LINK
HOW DO I DECLARE IN VB.NET DT AS TYPE DATE WITH FORMAT DD/MM/YYYY
DIM DT AS ??
Participant
1300 Points
407 Posts
Re: HOW TO DECALRE DATE IN VB.NET
May 21, 2013 06:26 AM|akhleshchauhan|LINK
try this -
Dim yourDate As String = DateTime.Now.ToString("dd/MM/yyyy")
You can also use DateTime.TryParseExact Method or DateTime.ParseExact Method to convert date in required format
http://stackoverflow.com/questions/4327895/converting-date-string-to-datetime-format-vb-net
Akhlesh Chauhan
Member
403 Points
248 Posts
Re: HOW TO DECALRE DATE IN VB.NET
May 21, 2013 06:26 AM|shriniwasshukla|LINK
Contributor
2720 Points
594 Posts
Re: HOW TO DECALRE DATE IN VB.NET
May 21, 2013 06:30 AM|Nikhil Tripathi|LINK
Please try like this.
Dim Now As DateTime = DateTime.Now
Or
dim date_time as DateTime = Date.ParseExact(txtDateAdded.Text, "dd/MM/yyyy", Nothing).Date
Or refer to below links.
http://www.dotnetperls.com/datetime-parseexact
http://blog.stevex.net/parsing-dates-and-times-in-net/
Nikhil Tripathi,
Web Developer,
Ahmedabad, India.
All-Star
21479 Points
5971 Posts
Re: HOW TO DECALRE DATE IN VB.NET
May 21, 2013 07:42 AM|salman behera|LINK
try
Sincerely,
Salman
All-Star
114593 Points
18503 Posts
MVP
Re: HOW TO DECALRE DATE IN VB.NET
May 21, 2013 11:11 AM|Rion Williams|LINK
By default a DateTime object will not handle any formatting (such as DD/MM/YYYY etc) as that will be handled depending on how you elect to output it through the .ToString() method as seen below :
If you would like more information on how you can format DateTime objects, you can see the following link on handling Custom Date and Time Formatting :