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

Question

Question

5 digit number date - Working with dates in Rules Formulas

asked on January 22

I want to format a date with a format that isn't available in the Date Time field formatting list (YYDDMM)

I can do this with a field calculation, but as I want to use this in multiple places, would prefer to use a Rule instead where I can simply pass in my date and get the formatted value back.

It appears that the Formula won't allow me to pass in the date directly from the Date picker field.  Therefore I am adding the selected date to a single line field called Date_Value.  I am passing the Date_Value into the Rules formula as a parameter.  When viewing the Data_Value field in the form, the date is displayed as a 5 digit number e.g. 45300.  

If for example I try using YEAR(%(Date_Value)) in the formular, I get the error "The function "YEAR" produced the error "The format of the "45300" cannot be understood.  Try changing the date."

I have tried setting the type for the Input Parameter to text, integer and and DateTime, none of these make a difference.  

I guess I need to convert the 5 digit date number before using it in the YEAR() function, but I can't find a function that converts it.  Can someone point me in the right direction please?  I don't know if I need to be passing in the value differently from the form, or if I can convert in the rule.

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on January 22 Show version history

Hi Marie

I was able to make this work after a bit of trial and error.

On the form I have the Date Field (in Date Form) and a Single line field for the new date.

When I enter the date into the Date field, the Rules formula returns the Converted Date as a string

Below is the configuration of the Rules Formula. The formula is:

RIGHT(TEXT(YEAR(%(DateInput))),2) & RIGHT(JOIN("",["0",TEXT(DAY(%(DateInput)))]),2) & RIGHT(JOIN("",["0",TEXT(MONTH(%(DateInput)))]),2)

This accounts for the if the month is seen as a single digit, it will return it as a 2 digit number (ie: 1 becomes 01)

On the Date Conversion field, the Lookup rule (formula) is as follows

0 0
replied on January 23

Thank you Steve, very clear instructions and I have got that working on my form.  I am sure I will be using similar formulas a lot in future for dates, so it's useful to understand how to manipulate them.

0 0

Replies

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

Sign in to reply to this post.