codeoxygen
asked on
how to convert DATETIME format to only date in C#
hi,
I am pulling data from the database, one of the column is date. even though time values is not saved in the table. its displaying default time in grid. I am using Eval() method for assigning value . Can any one help me. Thanks in advance
I am pulling data from the database, one of the column is date. even though time values is not saved in the table. its displaying default time in grid. I am using Eval() method for assigning value . Can any one help me. Thanks in advance
A couple of possible ways for you to consider:
Set a format for the grid cell that is date only.
Convert to a string and display that rather than a datetime.
ASKER
how convert in asp tag ? while binding with eval method
Hi codeoxygen,
one suggestion from my side, please retrive only date part from the database.So, it will
display only the date in the grid and it will not display date and default time in grid.
SELECT convert(datetime, '10/23/2016', 101) -- mm/dd/yyyy
for more time format details, please check the link. (you have to in database labels)
http://www.sqlusa.com/bestpractices/datetimeconversion/
one suggestion from my side, please retrive only date part from the database.So, it will
display only the date in the grid and it will not display date and default time in grid.
SELECT convert(datetime, '10/23/2016', 101) -- mm/dd/yyyy
for more time format details, please check the link. (you have to in database labels)
http://www.sqlusa.com/bestpractices/datetimeconversion/
Try using the below tag to format while using Eval
<%# Eval("DateTimeField", "{0:dd-mm--yyyy}") %>
<%# Eval("DateTimeField", "{0:dd-mm--yyyy}") %>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
if it is n Code behind page . What is the format
DateField.ToString("dd/MM/ yyyy")
ASKER
textbox.ToString("dd/MM/yy yy")
even after using this format time value is displaying. Can you help me. in any other option
even after using this format time value is displaying. Can you help me. in any other option