datediff and datepart abbreviations

When working with dates/times it can sometimes get a bit confusing when abbreviation options are introduced e.g. abbreviations may pad 0’s,use 24hr (HH) vs 12hr (hh) etc.
This post is simply a confirmation that abbreviations in datediff and datepart do return the same value.

DECLARE   @starts datetime = '2017-06-12 19:00:05'
		, @ends datetime = '2017-06-12 19:00:07';

SELECT    DATEDIFF(ss,@starts,@ends) AS diff_ss
		, DATEDIFF(s,@starts,@ends) AS diff_s
		, DATEPART(ss,@starts) AS part_ss	
		, DATEPART(s,@starts) AS part_s;


Leave a Reply