Yes me again :) ... I'm needing to select nodes based on a date - The user can select a date and I want to show nodes(Events) up to the date specified.
I was thinking the below .. But for some reason a voice in my head is telling me "I don't think its correct when you are using dates" ?? Is this the right way to do it?
Lee, Lee, Lee... Spend an hour looking over the umbraco.library functions as well as the Exslt functions available. Tons of stuff for date handling, among other things. Knowing what utils are available will save you gads of time.
In this case, maybe this is the function you want...
(Not trying to be sarcastic here, but I didn't spend the time learning the util functions early on and wasted a lot of time because of it. I'm legitimately trying to be helpful and recommend you NOT repeat my mistake. Okay? Okay.)
Wise words from Doug - DateGreaterThanOrEqual is the way to go!
If you are wondering what the problem with comparing the results from FormatDateTime, it's due to both values being strings (not dates, nor numeric) - so the XSLT/XPath can't compare them (using the less-than / greater-than operators).
...
Lee, another thought is that since you've been clashing horns with XSLT a lot recently, you might want to go down the C# (API) route - see how that works out for you? Obviously, I'm a massive fan of XSLT - it serves me well, but I recognise that it's not well-suited to everyone.
Read Aaron Powell's blog post about "Why I'm not a fan of XSLT" - there are many alternative ways to achieve results using Umbraco!
I am already using the DateGreaterThanOrEqual function in my query, but I couldn't find a DateLessThanOrEqual?? Which is why I went down the above route?
The problem is I need to get nodes up to/before a certain date not after?? So am I right in thinking this is not the right method to use??
@Doug - Thanks Doug, always appreciate your advice :) ... And to be honest I did/do look through the WIki but all the wiki pages are blank I tried to look at? So people like me have no idea what the heck they do, so have to post multiple pleading posts on the forum (lol) :(
@Lee - I definitely owe you a beer along with Doug @ Codegarden for the help/advice, I have read that post before and do use the API (And slowly getting my head round it) but on this occasion I am using Tims locator package and trying to extend/modify it and the way it works is all in his XSLT file so I'm a bit stuffed :(
Using Dates In XSLT?
Yes me again :) ... I'm needing to select nodes based on a date - The user can select a date and I want to show nodes(Events) up to the date specified.
I was thinking the below .. But for some reason a voice in my head is telling me "I don't think its correct when you are using dates" ?? Is this the right way to do it?
Any advice greatly appreciated
Lee, Lee, Lee... Spend an hour looking over the umbraco.library functions as well as the Exslt functions available. Tons of stuff for date handling, among other things. Knowing what utils are available will save you gads of time.
In this case, maybe this is the function you want...
umbraco.library:DateGreaterThanOrEqual(stringFirstDate, stringSecondDate)
(Not trying to be sarcastic here, but I didn't spend the time learning the util functions early on and wasted a lot of time because of it. I'm legitimately trying to be helpful and recommend you NOT repeat my mistake. Okay? Okay.)
cheers,
doug.
Wise words from Doug - DateGreaterThanOrEqual is the way to go!
If you are wondering what the problem with comparing the results from FormatDateTime, it's due to both values being strings (not dates, nor numeric) - so the XSLT/XPath can't compare them (using the less-than / greater-than operators).
...
Lee, another thought is that since you've been clashing horns with XSLT a lot recently, you might want to go down the C# (API) route - see how that works out for you? Obviously, I'm a massive fan of XSLT - it serves me well, but I recognise that it's not well-suited to everyone.
Read Aaron Powell's blog post about "Why I'm not a fan of XSLT" - there are many alternative ways to achieve results using Umbraco!
Good luck, Lee.
Hey Chaps, thanks again for posting with help :)
I am already using the DateGreaterThanOrEqual function in my query, but I couldn't find a DateLessThanOrEqual?? Which is why I went down the above route?
The problem is I need to get nodes up to/before a certain date not after?? So am I right in thinking this is not the right method to use??
@Doug - Thanks Doug, always appreciate your advice :) ... And to be honest I did/do look through the WIki but all the wiki pages are blank I tried to look at? So people like me have no idea what the heck they do, so have to post multiple pleading posts on the forum (lol) :(
http://our.umbraco.org/wiki/reference/umbracolibrary/dategreaterthanorequal
@Lee - I definitely owe you a beer along with Doug @ Codegarden for the help/advice, I have read that post before and do use the API (And slowly getting my head round it) but on this occasion I am using Tims locator package and trying to extend/modify it and the way it works is all in his XSLT file so I'm a bit stuffed :(
Got to love the old forum still... I searched for 'Umbraco DateLessThanOrEqual' in Google and this thread came up
http://forum.umbraco.org/yaf_postst2756p2_Select-a-node-depending-on-the-Day-of-the-Week-and-Time-of-Day.aspx
Quickie, before I head off for lunch ... DateLessThanOrEqual? Try swapping the parameters around in the DateGreaterThanOrEqual?
As one of the dates must be greater than the other... so the other is less than the first ... (I've gone cross-eyed!) ;-P
is working on a reply...