Remove Time from DateTime values returned in Query
25,175
Solution 1
SELECT convert(char(10), DataLog.TimestampUTC, 120) as TimestampUTC,
MeterTags.Name,DataLog.Data
FROM DataLog
INNER JOIN MeterTags
ON DataLog.MeterTagId = MeterTags.MeterTagId
WHERE DataLog.TimeStampUTC between cast(getdate() - 1 as date) and cast(getdate() as date) and
DataLog.MeterTagId Between 416 AND 462;
Solution 2
In SQL Server you can convert to Date
select Convert(Date, Convert(datetime, '2013/01/01 12:53:45'))
results:
2013-01-01
Author by
user2547340
Updated on August 23, 2020Comments
-
user2547340 over 3 years
With the help of you guys on here, I have the following SQL Query:
SELECT DataLog.TimestampUTC,MeterTags.Name,DataLog.Data FROM DataLog INNER JOIN MeterTags ON DataLog.MeterTagId = MeterTags.MeterTagId WHERE DataLog.TimeStampUTC between cast(getdate() - 1 as date) and cast(getdate() as date) and DataLog.MeterTagId Between 416 AND 462;
This returns a column "TimestampUTC" with YYYY-MM-DD hh:mm:ss. I'd like to drop the time within this column and only display YYYY-MM-DD.
Any help you could give would be really appreciated.
Thanks in advance.