How to convert week part of date correctly?
We are using Datameer 4.5.8. I need to be able to get the start date from a year-week string. There seems to be an issue with converting week parameter to date.
The following expressions are not being evaluated correctly:
AsDate("2014-01";"yyyy-ww") results in "Dec 29, 2014" should be "Dec 29, 2013"
Converting it back from date to week is also resulting in errors:
FormatDate(AsDate("01/01/2016";"MM/dd/yyyy");"yyyy-ww") results in 2016-53
FormatDate(AsDate("01/01/2012";"MM/dd/yyyy");"yyyy-ww") results in 2012-52
Please let me know if this is a known issue and if there are any work arounds.
Thank You
-
Official comment
Datameer uses Joda time. Full documentation for Joda time is available here: http://www.joda.org/joda-time/key_format.html In your example, you'll want to reference the year in conjunction with the week. The key-code for this is an "x" character instead of a "y" character.
In the context above, please use this function: AsDate("2014-01";"xxxx-ww") which results in Dec. 29, 2013.
Additionally, here are the conversions for the other examples that you've provided: FormatDate(AsDate("01/01/2016";"MM/dd/yyyy");"xxxx-ww") results in 2015-53 FormatDate(AsDate("01/01/2012";"MM/dd/yyyy");"xxxx-ww") results in 2011-52
I hope this helps!
Comment actions -
Since other customers were asking for such kind of functionality too, I've created a separate knowledge base article for how to extract the calendar week from a date-input-field.
Please sign in to leave a comment.
Comments
3 comments