Answered by:
help plz

Question
-
hi experts,
how to calculate the current age using functiods with dateof birth
here is my sample :
input is : <dateof birth>
output id : <>age>
Wednesday, August 29, 2012 12:53 PM
Answers
-
There probably are 3rd party functoids for this, but these things typically are solved using a scripting functoid.
Just connect the field with the birthdate and paste code like below in the functoid.
DateTime now = DateTime.Today; int age = now.Year - bday.Year; if (bday > now.AddYears(-age)) age--;
This thread on StackOverflow is all about calculating ages
If you want to be able to reuse the functionality, then think about building a class library and call this from a scripting functoid.
Jean-Paul Smit | Didago IT Consultancy
Blog | Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question.- Edited by Jean-Paul Smit Wednesday, August 29, 2012 1:07 PM
- Proposed as answer by Shailesh Kawade Wednesday, August 29, 2012 1:46 PM
- Marked as answer by Leonid GanelineModerator Wednesday, August 29, 2012 9:54 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:36 PM
- Marked as answer by gurram satish Saturday, September 1, 2012 7:36 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:37 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 1:06 PM -
Ok, so you can use BizTalk functoids, that is good news :-)
Then you don't need to resort to inline XSLT.
Basically all replies mention the 'Scripting functoid', but I get the feeling that BizTalk maps are new to you(?).
Then you need to read up on using the functoids: How to use inline C# in a scripting functoid
(this is the BizTalk 2010 link but the one above explains it better and although for BizTalk 2004 it is no different for BizTalk 2010)
This link on MSDN shows how to use inline C# and with this information (and the C# code provided by other repliers) you're probably able to turn that into the age functionality you need.
If not, please let me know where you're stuck.
Jean-Paul Smit | Didago IT Consultancy
Blog | Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question.- Edited by Jean-Paul Smit Wednesday, August 29, 2012 2:32 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 2:25 PM -
Hi,
you can use the script functoid provided by BizTalk Server to insert a given date of birth, invoke a method and get back the age as output.
There's either inline c#, jscript or writing your own external assembly, which implements the age calculation methods.
There's plenty of age calculation code snippet arround in the web, e.g.:
hth
Paul Endras
Endras IT Consulting | www.endras.deIf this answers your question and is a helpful post, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
- Marked as answer by Leonid GanelineModerator Wednesday, August 29, 2012 9:54 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:37 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 1:06 PM -
Hi Satish,
I you want to achieve this with Biztalk functoids, please use below functoids.
1. Date functoid ( current System Date)
2. String Left functoid ( to extract Year from Current Date and date of birth)
3. Subtraction functoid (to subtract the Year of Birth from Current Year)
Thanks,
Deepthi
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Friday, August 31, 2012 9:46 AM -
satish,
try like below...
<xsl:variable name="Age"> <xsl:choose> <xsl:when test="month-from-date(current-date()) > month-from-date($Birthday) or month-from-date(current-date()) = month-from-date($Birthday) and day-from-date(current-date()) >= day-from-date($Birthday)"> <xsl:value-of select="year-from-date(current-date()) - year-from-date($Birthday)" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="year-from-date(current-date()) - year-from-date($Birthday) - 1" /> </xsl:otherwise> </xsl:choose> </xsl:variable>
Regards - Rajasekhar.R ' Don't forget to mark the post as answer or vote as helpful if it does,
- Proposed as answer by DeepthiAdith Wednesday, October 10, 2012 9:12 AM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Monday, September 3, 2012 6:02 AM
All replies
-
Satish,
It should be fairly easy using scripting functoid (plain c# code) isn't it ? or am I missing something?
Regards,
Vijendra
Wednesday, August 29, 2012 1:03 PM -
Hi,
you can use the script functoid provided by BizTalk Server to insert a given date of birth, invoke a method and get back the age as output.
There's either inline c#, jscript or writing your own external assembly, which implements the age calculation methods.
There's plenty of age calculation code snippet arround in the web, e.g.:
hth
Paul Endras
Endras IT Consulting | www.endras.deIf this answers your question and is a helpful post, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
- Marked as answer by Leonid GanelineModerator Wednesday, August 29, 2012 9:54 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:37 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 1:06 PM -
as per our need using functiods or XSlt .
please send reply if u know ?
Wednesday, August 29, 2012 1:06 PM -
There probably are 3rd party functoids for this, but these things typically are solved using a scripting functoid.
Just connect the field with the birthdate and paste code like below in the functoid.
DateTime now = DateTime.Today; int age = now.Year - bday.Year; if (bday > now.AddYears(-age)) age--;
This thread on StackOverflow is all about calculating ages
If you want to be able to reuse the functionality, then think about building a class library and call this from a scripting functoid.
Jean-Paul Smit | Didago IT Consultancy
Blog | Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question.- Edited by Jean-Paul Smit Wednesday, August 29, 2012 1:07 PM
- Proposed as answer by Shailesh Kawade Wednesday, August 29, 2012 1:46 PM
- Marked as answer by Leonid GanelineModerator Wednesday, August 29, 2012 9:54 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:36 PM
- Marked as answer by gurram satish Saturday, September 1, 2012 7:36 PM
- Unmarked as answer by gurram satish Saturday, September 1, 2012 7:37 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 1:06 PM -
hi Jean-Paul Smi,
THANKS FOR YOUR REPLY , but i needed using script function with xslt code.
plase do u know ?
thanks
Wednesday, August 29, 2012 1:58 PM -
Your requirement is not exactly clear to me.
Do you need to use custom XSLT?
That would make things unnecessary complex in my view.
By using the Scripting functoid the requested functionality can be fulfilled pretty easy.
If you have to use custom XSLT you can start looking at this resource
I'm not fond of using custom XSLT if it is not absolutely necessary, because it drops the maintainability of your map and you're no longer able to use the BizTalk tools available for mapping.
Jean-Paul Smit | Didago IT Consultancy
Blog | Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question.Wednesday, August 29, 2012 2:10 PM -
hi Jean-Paul Smi,
i neede use with biztalk funtiods, oterwise goto 2 inline xslt.
if u konw send me sample xslt?
thanks
Wednesday, August 29, 2012 2:14 PM -
Ok, so you can use BizTalk functoids, that is good news :-)
Then you don't need to resort to inline XSLT.
Basically all replies mention the 'Scripting functoid', but I get the feeling that BizTalk maps are new to you(?).
Then you need to read up on using the functoids: How to use inline C# in a scripting functoid
(this is the BizTalk 2010 link but the one above explains it better and although for BizTalk 2004 it is no different for BizTalk 2010)
This link on MSDN shows how to use inline C# and with this information (and the C# code provided by other repliers) you're probably able to turn that into the age functionality you need.
If not, please let me know where you're stuck.
Jean-Paul Smit | Didago IT Consultancy
Blog | Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question.- Edited by Jean-Paul Smit Wednesday, August 29, 2012 2:32 PM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Wednesday, August 29, 2012 2:25 PM -
Hi Satish,
I you want to achieve this with Biztalk functoids, please use below functoids.
1. Date functoid ( current System Date)
2. String Left functoid ( to extract Year from Current Date and date of birth)
3. Subtraction functoid (to subtract the Year of Birth from Current Year)
Thanks,
Deepthi
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Friday, August 31, 2012 9:46 AM -
Hi deepthi,
already i tried as per ur suggestible functionds.
but the the output will not be agin.
it show some error in map.
please if u have any idea in xslt plz let me know?
Saturday, September 1, 2012 7:35 PM -
satish,
try like below...
<xsl:variable name="Age"> <xsl:choose> <xsl:when test="month-from-date(current-date()) > month-from-date($Birthday) or month-from-date(current-date()) = month-from-date($Birthday) and day-from-date(current-date()) >= day-from-date($Birthday)"> <xsl:value-of select="year-from-date(current-date()) - year-from-date($Birthday)" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="year-from-date(current-date()) - year-from-date($Birthday) - 1" /> </xsl:otherwise> </xsl:choose> </xsl:variable>
Regards - Rajasekhar.R ' Don't forget to mark the post as answer or vote as helpful if it does,
- Proposed as answer by DeepthiAdith Wednesday, October 10, 2012 9:12 AM
- Marked as answer by Leonid GanelineModerator Wednesday, October 31, 2012 11:15 PM
Monday, September 3, 2012 6:02 AM -
Thanks rajashekar, but not work ?Monday, September 3, 2012 4:15 PM