PDA

View Full Version : Dates


dbustin
March 29th, 2012, 02:09 PM
I have a job where the data came in yyyymmdd. I wrote a rule where it returns mm/dd/yyyy. Now a need a rule that turns it into January 10, 2011. I wrote this rule:

return FormatDate(Rule("Expire Date", "mm dd, yyyy"));

but it is returning the value as "u029efi0e29". Any ideas????

Thanks

Dan Korn
March 29th, 2012, 03:42 PM
I have a job where the data came in yyyymmdd. I wrote a rule where it returns mm/dd/yyyy. Now a need a rule that turns it into January 10, 2011. I wrote this rule:

return FormatDate(Rule("Expire Date", "mm dd, yyyy"));

but it is returning the value as "u029efi0e29". Any ideas????

Thanks
It looks like you have your parentheses in the wrong place. Also, you need to use "lm" to return the named month. Try this:
return FormatDate(Rule("Expire Date"), "lm dd, yyyy");

dbustin
March 30th, 2012, 04:47 AM
Thanks. The year returns as 1912 though. Any ideas?

Dan Korn
March 30th, 2012, 09:39 AM
Thanks. The year returns as 1912 though. Any ideas?
What's being returned from Rule("Expire Date")? Does that specify four digits for the year? If not, then it's ambiguous, and you need to fix either that other rule or the data it's using to include the full four-digit year specification.

You could also try this:
return FormatDate(DateFromString(Rule("Expire Date")), "lm dd, yyyy");
The DateFromString function assumes that any two-digit year less than 30 is in this century, but it's still just an assumption. You need to make sure you're working with four-digit years all the way through, or you're going to have an ambiguity. This is the Y2K problem revisited.

dbustin
March 30th, 2012, 09:43 AM
Thank You! Thank You!