none
how to retrieve date only form sql in c# RRS feed

  • Question

  • Retrieving the data from sql table I displayed it in datagridveiw. Here it displayed only dates in dates column, but when I generate its print preview, it shows date along with time. But I want to display date only. So How can I do it?
    Tuesday, April 16, 2013 6:44 PM

Answers

  • Use something like , Cast(col as date) when you are returning the data from SQL, this is happening because the datafridview is treating the columns as dataetime rather then just date.

    You might also try convert(varchar(20),colname,101) this would return the data as string and things should work unless you are doing something like customised datatable creation before assigning it to gridview.


    Abhinav
    http://bishtabhinav.wordpress.com/

    Tuesday, April 16, 2013 8:03 PM