Search This Blog

Showing posts with label Format DateTime into Quarter. Show all posts
Showing posts with label Format DateTime into Quarter. Show all posts

Monday, 26 November 2012

Format DateTime into Quarter

Format DateTime into Quarter
Most of the time, we format DateTime value in various formats like day, month year etc. If we have to format a DateTime value into Quarter, we can use following expression syntax
=Format(DatePart(DateInterval.Quarter, <Date Value>))

For instance,
=Format(DatePart(DateInterval.Quarter, cdate("11/26/2012"))) will result 4.
AND
="Q"+Format(DatePart(DateInterval.Quarter, cdate("11/26/2012")))+","+cdate("11/26/2012").Year().ToString() will result Q4,2012
AND in following expression, we are going backward to 4 quarters
="Q"+Format(DatePart(DateInterval.Quarter, DateAdd(DateInterval.Quarter,-4,cdate("11/26/2012"))))+","+DateAdd(DateInterval.Quarter,-4,cdate("11/26/2012")).Year().ToString()
Will result Q4,2011