![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - trying to separate and reformat the date and time [Thread Next] Re: trying to separate and reformat the date and timeTo: NULL Date: 2/6/2007 8:01:00 PM See my Calendar XSLT application, written almost five years ago. It uses the datetime library (datetime_lib.xsl), distributed with XSelerator. This is a library of XSLT 1.0 templates for working with dates and times. One can get it either by buying the XSelerator or by downloading its trial version. The link to the Calendar application is: http://www.topxml.com/code/default.asp?p=3&id=v20020711152545 Of course, such kind of transformations are now easier with XSLT 2.0. Cheers, Dimitre Novatchev "Chuck" <techserv-no-spam-for-me@topsecurityinc-dotcom> wrote in message news:eGU9VKmSHHA.3440@T...... > Hello, > > I need to take the below listed date and time in the XML and convert it > using XSL into a separate date and time element using the below mentioned > formats without the use of a function so that it is processor independent. > > Any ideas would be appreciated > > XML > > <ds_EventHistory xmlns="http://tempuri.org/ds_EventHistory.xsd"> > <EventHistory> > <Event_Date>2006-03-01 07:27:15</Event_Date> > </EventHistory> > </ds_EventHistory> > > XSL - Not sure how to modify this code to get the below listed date format > (it needs to also handle the day of the week) > > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:sd="http://tempuri.org/ds_EventHistory.xsd" > exclude-result-prefixes="sd" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:msxsl="urn:schemas-microsoft-com:xslt" > xmlns:user="https://www.domain.com/mynamespace"> > > <xsl:template name="long_date"> > <xsl:param name="date" /> > <!-- Day --> > <xsl:value-of select="number(substring($date, 7, 2))" /> > <xsl:text> </xsl:text> > <!-- Month --> > <xsl:variable name="month" > select="number(substring($date, 5, 2))"/> > <xsl:choose> > <xsl:when test="$month=1">January</xsl:when> > <xsl:when test="$month=2">February</xsl:when> > <xsl:when test="$month=3">March</xsl:when> > <xsl:when test="$month=4">April</xsl:when> > <xsl:when test="$month=5">May</xsl:when> > <xsl:when test="$month=6">June</xsl:when> > <xsl:when test="$month=7">July</xsl:when> > <xsl:when test="$month=8">August</xsl:when> > <xsl:when test="$month=9">September</xsl:when> > <xsl:when test="$month=10">October</xsl:when> > <xsl:when test="$month=11">November</xsl:when> > <xsl:when test="$month=12">December</xsl:when> > <xsl:otherwise>INVALID MONTH</xsl:otherwise> > </xsl:choose> > <xsl:text> </xsl:text> > <!-- Year --> > <xsl:value-of select="substring($date, 1, 4)" /> > > </xsl:template> > </xsl:stylesheet> > > <td> > <xsl:value-of select="sd:Event_Date"/> <------------ This > should be the date > <xsl:text> </xsl:text> > </td> > Date needs to look like this format... > Wednesday, March 01, 2006 > > > <td> > <xsl:value-of select="sd:Event_Date"/> <------------ This > should be the time > <xsl:text> </xsl:text> > </td> > Time needs to look like this format... > 7:27:15am > > Thank you in advance. > > > > | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
