Link to home
Start Free TrialLog in
Avatar of spiral
spiral

asked on

datagrid formatting problem!

i got a datagrid which i want to show the date
as "dd-mm-yyyy hh:mm:ss". the data in the sql server table
is defined as datatime. however, when i select the data
into a datagrid my data->
"01-12-2001 00:00:00" becomes "01-12-2001" in the datagrid. It just never shows the "00:00:00"
but if the data is "01-12-2001 23:59" it shows the data
in its orginal form eg '01-12-2001 23:59". how to solve this problem i have?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Not very sure if this can work for SQL Server:

Select Format(myDate,'dd-mm-yyyy hh:mm:ss') As myDate From myTable
Avatar of trkcorp
trkcorp

Well, I just did this:
1. Right click on the grid, select Properties.
2. Click the Format Tab
3. Select the date/time column from Format Item Combo.
4. Select Format Type = Custom
5. Format string text box appears, create a mask.  Mine looks like:
dd-mm-yyyy hh:mm:ss

The column data looks like:
01-02-2002 00:00:00
01-02-2002 01:01:01
02-02-2002 12:59:00
Please maintain your open questions:
Questions Asked 17
Last 10 Grades Given B A A B A B B B B  
Question Grading Record 9 Answers Graded / 9 Answers Received

Thanks,
Anthony
maybe u can try this in sql statement
select convert(varchar, myDate, 109) from tblTime
Avatar of spiral

ASKER



the answer which being propose doesnt work
ASKER CERTIFIED SOLUTION
Avatar of cnealy
cnealy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial