Adatis BI Blogs

What's New

  • Joins vs CROSS APPLY

    Every professional (who has worked with SQL Server) will have used a Join operator.   However, the same cannot be said about the APPLY operator.   Although APPLY was introduced back in SQL Server 2005, there are still a number of developers who have barely seen the syntax, let alone utilised it’s capabilities. This blog focuses solely on INNER...
    Posted to Callum Green (Weblog) by callumg on 04-07-2015
  • re: How to get an age from two dates in SQL

    I've had the following script pointed out to me by a colleague. It's an easier code to pull apart. DECLARE @Dob Datetime = '06-07-84' DECLARE @Datenow datetime = GETDATE() ;With Age AS ( SELECT DATEDIFF(YEAR,@Dob, @Datenow) As AgeYear ,DATEDIFF(MONTH,@Dob, @Datenow)%12 As AgeMonth ) SELECT * FROM Age
    Posted to Ust Oldfield's Blog (Weblog) by Ust Oldfield on 04-02-2015
  • How to get an age from two dates in SQL

    For a project that I’ve been working on recently I was tasked with finding the Age of a product at a certain point in time in year and months. What should have been a relatively simple task proved to be a bit more difficult as the requirement was that the age be returned in two separate columns: Years and Months. I approached it by using DATEDIFF as...
    Posted to Ust Oldfield's Blog (Weblog) by Ust Oldfield on 04-01-2015