user3167167
user3167167

Reputation: 93

Getting the minutes from a date time by subtracting

HI I Have 2 datetimes fields. One is appt_scheduled and the other is appt_confirmed.

I would like to know if the times are within 5 minutes. This would be an indication that the appointment was a 'walk-in' then the formula can display 'walkin' on the row.​ I guess we can say that the date part has to be the same.

typical values are:

2016-12-21 08:40:00.000 - 2016-12-20 15:42:19.890

Upvotes: 1

Views: 53

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270653

You can just use a case. Something like:

select (case when appt_confirmed < dateadd(minute, 5, appt_scheduled)
             then 'walk-in'
             else 'scheduled'
        end) as AppointmentType
. . .

This assumes the confirmation is always after the schedule (although that condition could also be checked).

Upvotes: 1

Related Questions