0

Could someone please help me to remove the timestamps from my query results?

My date/time column indicates the product delivery like this

12/14/2020 5:00:00 AM 

I really don't care about the time of the day but I like to have my entire date mm/dd/year.

Your help is greatly appreciated in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Does this answer your question? [Get only the date in timestamp in mysql](https://stackoverflow.com/questions/20228731/get-only-the-date-in-timestamp-in-mysql) – buddemat Dec 18 '20 at 16:42

2 Answers2

0

In SQL Server, you can cast() or convert() a datetime to a date:

convert(date, mydatetime) as mydate

... Where mydatetime is the column you want to convert.

GMB
  • 216,147
  • 25
  • 84
  • 135
  • Just out of curiosity - you're showing the `convert` - any reason you prefer this, over `CAST(mydatetime AS DATE)` ? Personally, I find the `CAST` a bit cleaner and "more obvious" - but that might just be me ..... :-) – marc_s Dec 18 '20 at 16:30
  • 1
    @marc_s: I pretty much navigate randomly between both. But I think you have a good point, I might "convert" myself to consitently using `cast()`! – GMB Dec 18 '20 at 16:42
0

If it is a date/time column, then use:

convert(date, col)

If it is a string (and it should not be):

left(col, 10)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786