Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL: Filter for Current Date

Status
Not open for further replies.

whodeycp

MIS
Oct 11, 2007
14
0
0
US
I have set up a webpage to display current conference room scheduling on a digital sign using XML data to load into the webpage using XSL. I want to be able to filter the XML entering the webpage by the StartDate that is specified in the XML by using the system current date. Does anyone have any example code that might help me in this struggle?
 
You can pass a param into the xsl document that you could use to store the system current date.

<xsl:param>

You would need to check on the correct forum for how you pass this through to your xsl file.
 
Simple... if your using the MSXML as your XSLT Processor this should work:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:date="myDateFunctions">

<msxsl:script implements-prefix="date" language="vb">
<![CDATA[

Public Function current(dateFormat As String)
Dim currentDateTime As DateTime = Date.Now
Return currentDateTime.toString(dateFormat)
End Function

]]>
</msxsl:script>

Then Output like this:

<xsl:value-of select="date:current('MM/dd/yyyy hh:mm:ss')" />

Simple huh?

Remember to always make a namespace/prefix for scrpits.. and to implemenet the prefix and the call the function with the prefix... simple.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top