Hello-
I'm looking for help turning something I've done into excel into a formula tool. In the data below, I'm trying to make a new field called 'new CSD/BSD'. In excel, this is done with '=C3-G3' or subtracting the Days of Service from the Hire Date, and then reformatting that number as a date. I can't seem to find the right formula.
Solved! Go to Solution.
Hey @katherinetdavita, for this we'd just use the DateTimeAdd() function. Make sure you put a - in front of the interval as you're taking days away!
@DataNath makes sense, but what's going on with the word "add" in the second row of the formula. I'm getting a parse error when I include that and also (if it's there in error) when I exclude it.
Oh sorry @katherinetdavita - just delete that! I must've left it in there by accident. The expression should just be the first line :)
DateTimeAdd([Hire Date],-[Days of Service],'day')
If you're still getting the error when you remove the 'add' on the second line, I think the most likely issue is that your [Days of Service] field is a string - just check the data type as it should be numeric. If not, can you post the error to help troubleshoot?
@DataNath I think you're right about the String. Here's the formula where the workflow calcs the Days of Service:
And here's the error after fixing the expression:
Ah yep that's it @katherinetdavita! At the moment, as the field is stored as a string, this is essentially the same as telling Alteryx to take away 'hello'! You're creating the field in the Formula tool and the default for new fields you make is a V_WString so this is quite a common thing to run into! Luckily there's 2 very simple ways of handling this.
1) Where you're making this [NEW Days of Service] field, just change the data type of it here to something numeric (Double, Int32 etc):
2) If you don't want to change the data type and do want this field stored as a string, temporarily convert it within the [New CSD/BSD] expression, like so:
DateTimeAdd([Hire Date],-ToNumber([NEW Days of Service]),'day')
Hope this helps!
Thanks @DataNath ! That took care of it! Will Accept as Solution now!
User | Count |
---|---|
107 | |
82 | |
69 | |
54 | |
40 |