Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to Get all the datas from table and bind that into Datalist. I have a fromdate and todate fields in my table. When i try to bind dates its displayed as Date with time format. I need to display date only. i am using stored procedure to get data.. How can i convert that Datatime format to date.......And where i can convert that, in my codebehind ? or stored procedure ?
Posted
Updated 8-Aug-13 19:55pm
v2
Comments
sumit_kapadia 9-Aug-13 2:01am    
What date format you want ... ie dd/MMM/yyy ??
SnvMohan 9-Aug-13 2:09am    
yeah that format....dd/mm/yyyy

Another way is to convert datetime data type to varchar data type using T-SQL CONVERT[^] function, for example:

SQL
SELECT CONVERT(VARCHAR(10), FromDate, 112) AS FromDate, CONVERT(VARCHAR(10), ToDate, 112) AS ToDate
 
Share this answer
 
You can do it in page itself
<%# DataBinder.Eval(Container.DataItem, "datetime", "{0:dd/mm/yyyy}")%>//Change format string(3rd)as you want

Regards..:)
 
Share this answer
 
v3
Don't.
Format the display information instead: MSDN[^]
 
Share this answer
 
Comments
SnvMohan 9-Aug-13 2:18am    
Thank you so much.....Its working for me
OriginalGriff 9-Aug-13 2:28am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900