-1

I am trying to show only date here and not the time but whatever i do still is showing the time like this format 4/4/2014 12:00:00 AM. I would like to remove the time portion of the date and only show the date. What am i doing wrong here? here is my sql

 SELECT
 DATEADD(DD, 
  CONVERT(INT, (DATEDIFF(DD, '1/1/1900', t.DT)/7)) * 7, '1/1/1900') [WeekBeginDate],                                 
  SUM(HOURS) AS TOTAL_HOURS
   FROM [DA2].[PMO].[TASK_TIME_TRACKER] t
    WHERE UID = 'John07'
    AND DT >= DATEADD(WEEK, -4, GetDate())
     GROUP BY CONVERT(INT, DATEDIFF(DD, '1/1/1900', t.DT)/7)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
moe
  • 5,149
  • 38
  • 130
  • 197

1 Answers1

0
DATEADD(DD, CONVERT(INT, (DATEDIFF(DD, '1/1/1900', CONVERT(DATE,t.DT))/7)) * 7, '1/1/1900')

You also need to change your group by expression to include the conversion. that will group each day together regardless of time, to display just the time you may need to wrap the whole line in an outer convert.

GROUP BY CONVERT(INT, DATEDIFF(DD, '1/1/1900', CONVERT(DATE,t.DT))/7)

What are you using to display the results? if it is SSRS you can change the format on the cell to date to drop the 0's that the timestamp would display.

Daniel E.
  • 2,029
  • 3
  • 22
  • 28