These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Date2Num function return zero

EmilyChang
Registered: Aug 8 2010
Posts: 10
Answered

dear all...

I want to convert the date to number string to calculate the Chinese year using Date2Num function, however, the value return is alway zero.

here is my script:

var nDateNum = Date2Num("$.formattedValue", "YYYY/MM/DD")
var cYr = (Num2Date(nDateNum ,"YYYY") - 1911)
var cMo = Num2Date(nDateNum,"MM")
var cDay = Num2Date(nDateNum,"DD")
$.rawValue = Concat(cYr,"年",cMo,"月",cDay,"日")

I've looked up many resourses from Internet and online help while I can't find out the solution!

Could someone have problem like mine before? Thanks so much!

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

did you check the pattern for the date field?
You can assign a pattern for chinese regions.
Select the date field and open the pattern menu in the value tab of the object palette.
Then select the region you need the pattern for and the one of the types that matched your needs.

date{YYYY'年'M'月'D'日'EEEE}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

EmilyChang
Registered: Aug 8 2010
Posts: 10
Thanks for your reply, radzmar!

I know that there are different patterns for many different regions I can choose and I did.
But the Year of all paterns is in A.D. and I have to convert the A.D. year to Chinese year
that is "A.D year - 1911"

so I need to use Date2Num to calculate.

My problem is that the value I get from Date2Num function is always zero...
Bamboolian
Registered: Jul 27 2010
Posts: 48
Hi,

Do you want the value to be in Chinese year? or do you just want it to display as Chinese year.

If you just want to change display, then check formCalc manual in your country language, and there should be some explanation on which date symbols to use for local date.
For instance, I use Japanese manual and there was instruction to use date symbol "ggg" for Japanese years.
if you select "Japanese" as locale and set following to Field/Patterns/Display/pattern
date{ggg YYYY'年'M'月'D'日'}
you'll get "平成22年9月14日" as display when you picked today from calender picker.

Unfortunatly I cann't read Chinese so I'm not sure if there is this kind of help in Chinese manual, but I'm assuming there is.
EmilyChang
Registered: Aug 8 2010
Posts: 10
Thank you Bamboolian!

I just want it to be display as Chinese year and the method you provided really helped me a lot.

But now I have another question!
The instance above was shown as "平成22年9月14日".
Is there any way to get only "22年9月14日"?

I tried to use "substring" while the string "22年9月14日" is only a display pattern.
so I can only get "2010-09-14"

Do you have better idea?
Bamboolian
Registered: Jul 27 2010
Posts: 48
Hi Emily,

I tried, but I guess locale year appears only at time this date symbol "g" or "gg" or "ggg" is used together.