Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert string into integer in jython fdmee

JanGLiApr 21 2017 — edited May 15 2017

Hi,

I want to subtract 1 year from my current year.

This is how i am getting the year

Qyearfull = "20" + fdmContext["PERIODNAME"][4:]

I want to get previous year.

I thought i could convert Qyearfull into integer and subtract 1 from it.

This is how i tried int(Qyearfull) but getting error.


Any idea how can i convert string into integer.

Regards

This post has been answered by JohnGoodwin on Apr 21 2017
Jump to Answer

Comments

SH_INT

What error are you getting? Are you sure the string you are trying to convert only contains numeric characters? The method you are trying will work so long as the string is just a representation of a number

JanGLi

The value is 100 percent integer (2017). I have confirmed it by logging.

I even tried using this x = int('19') but getting an error.


Unfortunately i don't have python compiler at the moment. Getting just script fail error in log.

These are the classes i have added:

import string

import java.sql as sql

import java.lang as lang

Regards

JohnGoodwin
Answer

This works for me, no need to import java classes

fdmAPI.logDebug("Period Name=:%s" % fdmContext["PERIODNAME"])

fullYear = int("20" + fdmContext["PERIODNAME"][4:])

fdmAPI.logDebug("Full Year Name=:%s" % fullYear)

pastedImage_2.png

or

YearMinus1 = int("20" + fdmContext["PERIODNAME"][4:])-1

fdmAPI.logDebug("Year -1=:%s" % YearMinus1)

pastedImage_3.png

Cheers

John

Marked as Answer by JanGLi · Sep 27 2020
JanGLi

Thanks for help.

Regards

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 12 2017
Added on Apr 21 2017
4 comments
780 views