Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With the time data type (I'm using Microsoft SQL Server 2008), is there any way to take only the minute part out of it? I tried to pass the time to datepart and datediff function but both refused to work.

Example: I want to get 15 from 04:15

share|improve this question
What do you mean, "refused to work"? See my answer below. Those examples give the desired output. – Thomas Stringer Apr 18 '12 at 16:35
up vote 5 down vote accepted
select datepart(minute, '04:15')

Utilize the DATEPART() function, with minute as the datepart param.

declare @current_time time

select @current_time = getdate()

select datepart(minute, @current_time) as current_minute

BOL Reference on DATEPART

share|improve this answer
I strongly recommend the habit of specifying explicitly the datepart, e.g. MINUTE instead of MI. There are too many shorthand formats that are ambiguous to justify saving a few keystrokes. This very thing gets its own dedicated slide in my popular "Bad Habits to Kick" presentation. :-) – Aaron Bertrand Apr 18 '12 at 17:15
@AaronBertrand Good point, and a great suggestion. I've edited my post to reflect! – Thomas Stringer Apr 18 '12 at 17:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.