6 Replies Latest reply on Mar 4, 2019 8:50 AM by Nirmal Shah

    DATETRUNC & DATEPART- Explained: 'day', 'month', 'quarter', 'year' - The Dummy Version

    Stephen Groff

      I grew up in the 80s, coding was just getting started and I missed the bus by the early 90's because I was too busy watching reruns of Full House when I got home from school instead...  So my brain didn't develop this rapid lurch towards syntax knowledge like some of the new millennials... but I'm trying... with some help.


      I can read the descriptions found here: https://onlinehelp.tableau.com/current/pro/desktop/en-us/functions_functions_date.html


      However, I need an idiot-proof explanation... and scouring the internet doesn't provide me with vernacular that my brain can create relationships with, so I'm asking for your help.


      I know we don't all understand LODs, but I'll use it in this example:


      { FIXED [Date]:COUNTD([Serial Number])}



      { FIXED DATETRUNC('day', [Date]):COUNTD([Serial Number])}



      { FIXED DATETRUNC('month', [Date]):COUNTD([Serial Number])}



      { FIXED DATETRUNC('year', [Date]):COUNTD([Serial Number])}



      { FIXED DATEPART('day', [Date]):COUNTD([Serial Number])}



      { FIXED DATEPART('month', [Date]):COUNTD([Serial Number])}



      { FIXED DATETPART('year', [Date]):COUNTD([Serial Number])}



      What is this calculation syntax telling Tableau to do?


      When this calculation gives me a number, what does this number represent in the example context?