I have a set of data that I would like to add a column with date format YYYY-MM-DD as shown below. Looking at columns A and B to determine the month and year. Ideas?
Solved! Go to Solution.
@traceystone
I can think of two ways
1. Use the DateTimeParse function to convert the string 'yyyy-mm' in to Date format data
2. Use the DateTime tool to parse the string 'yyyy-mm' in to Date format data
of course, the Year and month in your date look like integer, we need first convert them to String.
The target is "yyyy-mm-01", the first.
yyyy comes from [a]
- comes from "-"
mm comes from padleft([b], 2, "0")
-01 comes from "-01"
put it all together:
[a]+"-" + padleft([b],2,"0") + "-01"
If a or b are not strings, put a select in front of the formula tool and switch them.
that's how I might solve the challenge.
cheers,
mark
I get nulls both ways. Says that YearMonth is not a valid date
Can you check the date type of YearMonth, it should be String Type, rather then Date.
Well how bout that.. I missed that field when I added the formula. Thank you..