-3

I have a table called Jobs which has several columns, One of the column being ProofDate Column. Now the Column shows the date and as well as time.. I want to display the entire table in a tab of windows form application along with the ProofDate..But The proof Date must show only the Date and not the time..Can anyone help me with it??

  • 2
    Can you show us your existing code? – mjwills Jun 21 '17 at 09:55
  • 1
    Possible duplicate of [How to remove time portion of date in C# in DateTime object only?](https://stackoverflow.com/questions/6121271/how-to-remove-time-portion-of-date-in-c-sharp-in-datetime-object-only) – mjwills Jun 21 '17 at 09:55

3 Answers3

1
Select CONVERT(DATE, ColumnName) From Table

Would give you just the date of a column which is datetime

dbajtr
  • 2,024
  • 2
  • 14
  • 22
0

Applications and databases work best when you leave DateTime as complete DateTime objects, and the best time to change that format is when it is time to display the information

Leave the SQL query alone, use one of the DateTime.ToString methods to just the Date portion. There are plenty of canned methods as well; such as ToShortDateString().

Mad Myche
  • 1,075
  • 1
  • 7
  • 15
-2

if your ProofDate column is datetime as datatype then you can use below query.

select col1, col2, col3, convert(date,ProofDate ) as colname from table
Sreetam Das
  • 3,226
  • 2
  • 22
  • 36
  • When this is brought into the C# app this will either became a "full" DateTime again set to midnight. And you don't have a format style in your convert – Mad Myche Jun 21 '17 at 10:48
  • yeah it can be done on c# code by using toshortdatestring method @MadMyche – Muhammad Shariq Jun 21 '17 at 11:16
  • Yes, the `ToShortDateString()` method will return a string just containing the _Date_ portion of the value. However; if the data type is of the `DateTime` type it will once again be a DateTime value. The string function should only be used on the presentation/ display level – Mad Myche Nov 14 '17 at 16:38