Ask a questionAsk a question
 

AnswerSorting question

  • Tuesday, November 03, 2009 9:07 PMNHBuckeye Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have to "group by" purchase date, but the database's purchase date includes the time as well.  So when I group by purchase date, it includes the time as part of the date. Since the times are unique, I don't get "grouped by" info.  Is there a way to write a sql command to group by date while ignoring the time stamp?  The date part of the information consistently takes up the first 10 digits.

    Thanks!!!

Answers

All Replies

  • Tuesday, November 03, 2009 9:32 PMrok1 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You're in wrong forum.

    group by CAST(convert(varchar,purchaseDate,101)as datetime)
  • Wednesday, November 04, 2009 12:33 PMBikash Dash Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
    Please use T-SQL forum for this.

    As said by rok1 you can use

    group by CAST(convert(varchar,purchaseDate,101)as datetime)

    instead of group by purchaseDate

    Please Vote & "Mark As Answer" if this post is helpful toyou.

    Cheers
    Bikash Dash
    MCDBA/MCITP