Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help formatting date in a grid, region dependant?

Status
Not open for further replies.

Transcend

Programmer
Sep 29, 2002
858
AU
Hi everyone
I have come across a situation in an application where the date format in a grid is not consistant.

What i mean is that they are displaying like so

17/09/2003 11:53:23 AM
17/09/2003 9:34:30 AM
17/09/2003 11:53:22 AM
9/09/2003 11:55:08 AM

i.e. the leading zero's on the day and on the hour seem to get stripped out.

What we want to see is this

17/09/2003 11:53:23 AM
17/09/2003 09:34:30 AM
17/09/2003 11:53:22 AM
09/09/2003 11:55:08 AM

I can't simply put an edit mask on here because the application is used both in Australia and America
where the date is viewed slightly differently.

The SQL query returns the dates like so:

2003-09-17 01:50:39.000
2003-09-17 01:52:02.000
2002-11-07 00:14:03.000
2003-09-11 02:19:54.000


so it seems to be ADO that is stripping out the leading zeros in question.

How can i force the day and the hour to have leading zeros ??

Transcend
[gorgeous]
 
You can set the NumberFormat property for the column in the datagrid.
[tt]
If Country = "Australia" Then
DataGrid1.Columns(2).NumberFormat = "yyyy-mm-dd hh:nn:ss"
Else
DataGrid1.Columns(2).NumberFormat = "mm-dd-yyyy hh:nn:ss"
End If
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top