Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Help please can anyone advise how I get current date, or today method in xslt 1.o SharePoint

share|improve this question
add comment

2 Answers 2

When you add a DVWP to the page in SharePoint Designer, SPD defined a variable which contains the current date for you in the ParameterBindings section:

<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>

Be sure to declare Today as a param at the top of the stylesheet:

<xsl:param name="Today" />

Then you can use $Today however you need it.

The ddwrt:Today() function is also useful, but there's no real need for it when SPD is already handing you the value.

share|improve this answer
    
Thanks everyone –  Mighty Jul 9 '12 at 14:04
    
@Mighty it's customary to mark one correct answer as the accepted answer. –  David Clarke Mar 7 '13 at 23:32
add comment

I'm not sure if XSLT 1.0 have today's date method. However, XSLT 2.0 has an equivalent current-date()

Have you tried?

ddwrt:Today()

<xsl:value-of select="ddwrt:Today()"/>

ddwrt:TodayIso()

<xsl:value-of select="ddwrt:FormatDateTime(ddwrt:Today(),1033,'yyyyMMdd')"/>
share|improve this answer
5  
Note that SharePoint still uses the XSLT 1.0 spec (as of SharePoint 2010) so XSLT 2.0 functionality won't help. –  Marc D Anderson Jul 10 '12 at 2:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.