You are viewing limited content. For full access, please sign in.

Question

Question

Display date as which Quarter of the year

asked on March 29, 2017

Hi,

 

I am trying to format a WF token so that the date is converted into the specific QUARTER that date is in.  I can see the I can use "QQQQ" or "qqqq" to display "1st Quarter", but it doesn't seem to be working.

 

In the token setup window, I am pulling the Date from my Template and trying to add the format QQQQ so that I can use this to name a folder where the document will be saved.

 

Any ideas as to what I am doing wrong?

 

Thanks,

Anthony

1 0

Replies

replied on March 29, 2017 Show version history

QQQQ is not a valid format specifier.  Here is how I would solve it:

Note that you may want to add Fourth Quarter Branch Conditions and then add a 5th branch to handle a blank dates so that a blank does not get assigned to 4th Quarter.

2 0
replied on March 29, 2017

Like most things there are several ways to accomplish what you are looking to do.  Bert's suggestion of a conditional workflow is a good one.  The other options include a small script activity or one of the Qfiche Toolkit custom workflow activities.

If you are comfortable with the Script activity here is a code snippet that will return the quarter for a given date;

        Protected Overrides Sub Execute()
            Dim quarter As String = "???"

            Try
                Dim actualDate As DateTime = CDate(Me.GetTokenValue("DateToEvaluate"))
                quarter = "Q" & Microsoft.VisualBasic.DateAndTime.DatePart("q",actualDate).ToString

            Catch ex As Exception
                Me.WorkflowApi.TrackError(ex.Message)

            End Try

            Me.SetTokenValue("Quarter", quarter)

        End Sub

The Script activity is looking for a token called 'DateToEvaluate' and returns a token called 'Quarter'.  Here is a screen snip of the bare bones workflow;

The other option is to download and install the Qfiche Toolkit Date Tokenizer custom workflow activity from the Qfiche Products webpage at www.qfiche.com\Products. Once installed the custom workflow activity will allow you to tokenize a datetime value into any of the following formats; For Date Values: Day, Days In Month, Day Of Year, Month, Month Name Long, Month Name Short, Quarter, WeekDay, WeekDay Name Long, WeekDay Name Short, Week Of Year, Year, Julian Date, Ordinal Date. For Time values: Second, Minute, Hour, AM/PM.   Here is a screen snip of a bare bones workflow using the Date Tokenizer activity;

 

1 0
replied on March 30, 2017

Thank you all for your answers, they are all very helpful.  I have implemented Bert's version but will look at the QFiche options available.

 

I was surprised that evaluating the Quarter from a given date was not a standard option within WF, perhaps this is something which could be added in the future?

 

Anthony 

0 0
replied on March 30, 2017

For future reference, you can get the Date Token specifiers from:

Token Formatting--Date and Time

0 0
replied on March 30, 2017

Thanks, I saw this.  I was just shocked that Quarter wasn't/isn't included.

 

Anthony

0 0
replied on April 4, 2017

We're using Microsoft .NET for date formatting and they're not supporting it.

Courtesy of the internets, the formula looks to be Int((Month -1)/3) +1, so you can do it with Token Calculator, using the integer division function: (%(Date#"M"#) -1)// 3 + 1

 

 

0 0
replied on April 27, 2017

Thanks for all your help!  So much detail in the answer, which is reassuring that so many people are willing to help.  Thanks again!

Anthony

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.