I have a SP that will compare a datetime field with today's date
I also want to extract the time only for a separate column
I tried the following:
DECLARE @today [DATETIME] = CONVERT([DATETIME], CONVERT([DATE], GETDATE()));
Open in new window
The first one will return todays date with zeros in the time part of the field (2017-04-18 00:00:00.000)
In order to compare to my "date_start" field which contains time, I need to 'remove' the time portion or make it all zeros.
I tried using the
DECLARE @datetime_start_today [DATETIME] = CONVERT([DATETIME], CONVERT([DATE], datetime_start));
Open in new window
I get an error saying 'datetimestart' field does not exist, when in fact it does.
Once that is fixed (I assume my syntax is incorrect). I need to compare both dates
WHERE @datetime_start_today = @today
Open in new window
The above should compare only the dates and not the times.
Finally I also want to extract the time only so it shows on the screen as "10:00 AM" for example