Quantcast
Channel: Data Preparation & Blending discussions
Viewing all articles
Browse latest Browse all 4999

How to add a column to return the date values as Today, MTD, QTD, & YTD

$
0
0

I have a question on how to get a field to return the following values: Today, MTD, QTD, YTD.  

*Where YTD = October 1st of the previous year as the start of the YTD.  For Example: This year's YTD = October 1, 2016 to present.

 

If Today = Monday THEN return Friday, Saturday, Sunday = "Today"

If Today is NOT Monday THEN return yesterday = "Today"

THEN return all dates for the month = "MTD"

THEN return all dates for the quarter = "QTD"

THEN return all dates for the year = "YTD"  (YTD starts = October 1, 2016)

 

The first part of my question (Monday vs the rest of the work week) was answered in a previous post and seems to be working correctly:

IF DateTimeFormat(DateTimeToday(), "%a") = "mon"
THEN DateTimeDiff(DateTimeFormat(DateTimeToday(), "%Y-%m-%d"),DateTimeFormat([OppSystemCloseDate],"%Y-%m-%d"),"days")<4
ELSE DateTimeFormat([OppSystemCloseDate],"%Y-%m-%d") = DateTimeFormat(DateTimeAdd(DateTimeToday(), -1, "days"), "%Y-%m-%d")
ENDIF


Viewing all articles
Browse latest Browse all 4999

Trending Articles