|
-
Sep 29th, 2009, 08:06 AM
#4
Re: convert text to dd/mm/yyyy format
 Originally Posted by tkoletsis
I'm trying to convert the "29/09/2009" string to date format dd/mm/yyyy
I'm using visual studio 2008, and i've tried the following:
dim sdate as string
sdate = "29/09/2009"
mydate = DateTime.Parse(sDate, Globalization.CultureInfo.CreateSpecificCulture("el-GR"))
and
mydate = Date.Parse(sDate).ToShortDateString()
and i always get #9/29/2009# instead of #29/09/2009# that i want
Any help please?
A Date is a Date is a Date. Dates don't have formats because they are binary values. Only string representations of dates have format. When you see #9/29/2009# that does NOT mean that your Date has that specific format. That's simply how VS represents Date literals. The value of the date is the value of the date.
Consider this. If you were to write this code:
vb.net Code:
Dim number As Integer = &HFF
and the you check the value of the variable, VS would tell you that the value was 255. Does that mean that the number has a decimal format instead of a hexadecimal format? Of course not. The number is stored in the computer in binary form, as is everything. 255 is just the way that VS represents the numeric literal.
Dates are the same. A Date is just a number stored in the computer in binary form. The number represents a number of milliseconds since a specific point in time. How can that have any format? A Date is simply a value that represents a point in time. Format is ONLY an issue when you want to display that value, at which point you need to convert it to a string, at which point you need to decide what format to use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|