473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Lasy day of the month

hi,

Could someone please tell me how to calculate the last day of the month, from the month number given, for example: 9, 10? ie find the last day of sept. or oct. , using xslt 2.0?

Thanks
.
Jan 3 '08 #1
4 1693
jkmyoung
2,057 Expert 2GB
say value is in $month
<xsl:value-of select="document('')//month[@number=$month]/@last"/>

<my:mapping xmlns:my="internal">
<month number="1" last="31"/>
<month number="2" last="28"/>
<month number="3" last="31"/>
<month number="4" last="30"/>
<month number="5" last="31"/>
<month number="6" last="30"/>
<month number="7" last="31"/>
<month number="8" last="31"/>
<month number="9" last="30"/>
<month number="10" last="31"/>
<month number="11" last="30"/>
<month number="12" last="31"/>
</my:mapping>
Jan 3 '08 #2
say value is in $month
<xsl:value-of select="document('')//month[@number=$month]/@last"/>

<my:mapping xmlns:my="internal">
<month number="1" last="31"/>
<month number="2" last="28"/>
<month number="3" last="31"/>
<month number="4" last="30"/>
<month number="5" last="31"/>
<month number="6" last="30"/>
<month number="7" last="31"/>
<month number="8" last="31"/>
<month number="9" last="30"/>
<month number="10" last="31"/>
<month number="11" last="30"/>
<month number="12" last="31"/>
</my:mapping>
hi, this does not work, because I have to show the whole date, i.e. 31.09.2008.
And will this code work in xslt 2.0?

thanks
Jan 4 '08 #3
jkmyoung
2,057 Expert 2GB
Then put <xsl:value-of>'s to show your month and year.
XSLT 2.0 is backwards compatible to 1.0, except for very few exceptions which no one uses anyways.
Jan 4 '08 #4
This code works fine for 3 out of 4 years ... but what about leap years? Every fourth year February has 29 days. But wait ... that is except every 100th year ... when it doesn't! Ie: generally, there are 24 leap years every 100 years. But wait ... again ... that is, except for every 400th year! Which is a leap year .... so you have 24 leap years every 100 years for 300 years and then 25 leap years for the next 100 years. Totally confused? I thought so! Here's a piece of generic code that explain it!

if year modulo 400 is 0 then leap
else if year modulo 100 is 0 then no_leap
else if year modulo 4 is 0 then leap
else no_leap
endif

Someone might like to bash that into XML and paste it back in this thread.

Cheers

virgil.
Jan 7 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Finlay | last post by:
Hi Group I am designing a report that should show a meter reading for each month and the previous meter reading for the previous month. The months are text stored in a field tMonth. The...
6
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a...
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
4
by: Ronald Celis | last post by:
Hi, is there anyway to get the Number of days in a given month and Year in C# thanks Ronald Celis
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
4
by: gabor | last post by:
hi, i'm trying to get the date of the day one month ago. for example: today = 12.apr.2006 one-month-ago = 12.mar.2006 so:
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
19
by: edfialk | last post by:
Hi, does anyone happen to know of a script that would return the number of seconds in a month if I give it a month and a year? My python is a little weak, but if anyone could offer some...
6
by: Nkhosinathie | last post by:
hello guys,i've started with classes and i've been given this program below to program and also i will post the source code if you need it.this program reads as folllows. create a class called...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.