Date format

chand

Freshman
Joined
Feb 4, 2004
Messages
30
Hi i am using .net and sql server data base.i am getting date value like '02/07/2004'.i want to show it to user on the form as '02/07/04'. how can i show without 2 digit year part like that. b'coz they want to enter only year 2 digit part. i would appreciate if any help
 
hi i still have a problem.here is mycode and problem
i am going through all date format posts but i am having problem datetime to convert
.i am using sql server and my date field is datetime.i am getting value from db as 01/02/2004 but i
want to show it to user as 01/02/04. i have many date fields in my application so i am trying to write function
and call it wherever i want.but iam not able to get it.if anyone helps me i would appreciate.
here is my code for function

Public Function fndateFormat(ByVal value As DateFormat, ByRef ds As TextBox)
Dim ci As System.Globalization.CultureInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")
Dim d As DateTime = DateTime.Parse("value", ci)
Dim s As DateFormat
s = d.ToString("MM/dd/yy")
End Function

here is my actual code .i am displaying data from dataset

If oDs.Tables(0).Rows.Count <> 0 Then
txtActionNo.Text = Trim(oDs.Tables(0).Rows(0)(0))
fndateFormat(oDs.Tables(0).Rows(0)(1), txtDateCreated)
txtCrNo.Text = Trim(oDs.Tables(0).Rows(0)(2))
 
Hi,
As you can see I had a similar problem. To solve this I selected the correct region settings in SQL server so it saves my dates as I want them. In Britain, 1st of March 2003 will show as 01/03/2004.
However, In USA it would show as 03/01/2004.
So, to show my dates correctly, I selected British English in the SQL server setting and my problem was solved. It saves having to convert the date from one format to another if you save it the way you want in the first palce!
 
ohhhhhhhhh:

why not:

Label1.Text = ((DateTime)yourDataRow["TimeField"]).ToString("dd/MM/yy");

Never read anything about format-strings?
 
Back
Top