473,323 Members | 1,574 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,323 software developers and data experts.

Get year from dateTime

Hello,

I don't know how to get year from dateTime.

My xml:
<P>
<A>
<Time>
<TimeBeginning>2006-04-01T08:00:00</TimeBeginning>
</Time>
</A>
</P>

Now I have this, but it does not work.
<xsl:for-each select="P/A">
<p><xsl:value-of select="year-from-dateTime(Time/TimeBeginning)"
/></p>
</xsl:for-each>

All dates in xml are in this format (2006-04-01T08:00:00).

Can you help me?
Thanks

May 26 '06 #1
6 3957
First question: Are you using an XSLT 2.0 processor? 1.0 doesn't have
any built-in support for schema datatypes, and would need an assist from
an extension function.
May 26 '06 #2
I really don't know. I am writing this in Notepad and watching in
firefox 1.5.0.3.
Where can I see which XSLT processor I use?

May 26 '06 #3


Pravljica wrote:
I really don't know. I am writing this in Notepad and watching in
firefox 1.5.0.3.
Where can I see which XSLT processor I use?


Firefox 1.5 (well all current Firefox versions) use Transformiix as an
XSLT processor and that processor supports XSLT 1.0 and XPath 1.0.
Any date, time, dateTime functions are part of XPath 2.0 and not
supported by Firefox's built-in processor.
You would need to use Saxon 8 from http://www.saxonica.com/ if you want
an XSLT 2.0 processor.
On the other hand extracting the year is easy with XPath 1.0 string
functions
substring(Time/TimeBeginning, 1, 4)
--

Martin Honnen
http://JavaScript.FAQTs.com/
May 26 '06 #4
Thanks Martin, this works.

I have also instaled MSXML 4.0 SP2 Parser and SDK. Is this in some
connection with XSLT processor?

If I install saxonica - will my documents work on computers that don't
have saxonica installed? Probably not :)

May 26 '06 #5


Pravljica wrote:

I have also instaled MSXML 4.0 SP2 Parser and SDK. Is this in some
connection with XSLT processor?
MSXML 4 has an XSLT 1.0 processor.
If I install saxonica - will my documents work on computers that don't
have saxonica installed? Probably not :)


The company is named Saxonica, the XSLT processor is called Saxon. And
yes, Saxon 8 needs to be installed to allow for XSLT 2.0 processing. So
far XSLT 2.0 is only a candidate recommendation, once it has become a
W3C recommendation it is likely there will be other implementations
besides Saxon.

--

Martin Honnen
http://JavaScript.FAQTs.com/
May 26 '06 #6
Thanks for this explanation.
I will stick with XSLT 1.0 for now.

May 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Hunter | last post by:
>>> from datetime import date >>> dt = date(1005,1,1) >>> print dt.strftime('%Y') Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: year=1005 is before 1900; the...
2
by: | last post by:
Hi!! know someone how to get a week span with week number and year? something like hi: public static DateTime GetWeekSpan(int weekNumber, int year) { DateTime weekStartDate = new...
4
by: Alan Silver | last post by:
Hello, I have a user control that has a property StartYear. Logically enough, this takes an Int32 value. I have no problem doing something like ... <ctls:fred id="frdFred" StartYear="2000"...
4
by: RP | last post by:
I have a date entered in a TextBox. On this TextBox LostFocus, I want to retrieve the year part and then calculate the difference from current year.
2
by: =?Utf-8?B?Sm9lIFRhdmFyZXM=?= | last post by:
I am using the DateTime.Parse method to parse user entered dates. The dates can be just the year, Month-year and Month-day-year in a variety of formats in a variety of cultures. I immediately parse...
2
by: O.B. | last post by:
Does C# provide an operation for converting year and day-of-the-year (1-365) to a DateTime object?
3
by: shapper | last post by:
Hello, I am checking a DateTime variable to check if in range: low < MyDateTime < high. However, I know need do the same but not care about the year. Can I do this? Thanks, Miguel
14
by: Tommy Jakobsen | last post by:
Hi. Is there a method in .NET that takes "year" as an argument and returns the total number of weeks in that year? For culture da-DK (Danish). Thanks in advance. Tommy.
3
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there a way if you are given a Year and a Week an easy way to go back say 26 weeks ago from given year/week. for example, given: 2008/16 26 weeks prior is: 2007/43 thanks,
4
by: hallsers | last post by:
Here is the problem i am having: - When a user logs in, on page load it will take the dob of all users in a stored friends list and compare them against the following conditions - To display any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.