Please can any ove suggest me how i can remove time part from sql dates. I have already read 100s of articles and most of them remove the time but leaves 00:00:00 behine which i don't want also i know that i can remove these ZERO's by doing a convert to varchar but unfortunately i cannot change the type of the date column it has to be date type instead of string
Please advise
Thanks
A datetime column in the database will always contain both a date portion and a time portion. SQL Server 2008 introduces types that store only date or only time. But, so long as the column is of type datetime, you'll have to accept that the time portion exists, and you can just ignore it in your application (by applying suitable formatting).
You can add a check constraint to the table to ensure that all entries in the column always have the same time portion (e.g. 00:00:00).
You need to apply a format string to your gridview column to only display the date part. An example of such a string would be dd MMMM yyyy
Is this an ASP.NET gridview? If so there is example code here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With