This week I was making a modification to our team site that I thought might be helpful for others in the SharePoint community
I have date column where I have a number of entries that show just the month and the year. My problem is trying to the the months to order correctly, i.e Jan, Feb, Mar etc. What I have is Apr, Aug, Dec etc
More searching didn’t turn up any other solutions. I tried various vbscript/excel functions in the calculated field to no avail. Then I started thinking clientside. I figured that if I could identify the fields in the list display, I should be able to manipulate them with jQuery. A quick search turned up a nice little piece of code by Paul Grenier on EndUserSharePoint.com. He has written a series entitled jQuery for Everyone and one of his articles was on Replacing [Today]. In his article, Paul talks about replacing a DateTime field with an Aging calculation. His article calculates a DateTime from the last modification date.
If you look at the progression we took on these three “versions”, this last one references the “Serial Number” column, which references each of the three date columns (“Year”, “Month”, and “Day”), which each run a function to grab a specific piece of our original date field. Since we’ve converted the original date into a SharePoint serial number, and broken the original date down into its individual pieces, this approach makes the most sense since the work is already being performed – we’re just going to repurpose it when needed.
Once updated, the values displayed on the list should be the same since we’re using the same formula – the only difference is that we’re performing the calculations in separate columns instead of within the actual “DATE” function itself (the logic is still the same though as to what being processed because each referenced column will perform its function then pass its value back to its calling column – the “Serial Number” column).
Sounds like a pretty reasonable suggestion and the Calendar lists NewForm.asx already sets the Start time to the current time – shouldn’t be too hard, right?
In continuance of the series on the “Date and Time” set of functions that I wrote about back at the end of May (that darn “Work” always getting in the way), I’d like to discuss the actual “DATE” function itself in order to help address some of the more frequent questions regarding how to deal with dates in SharePoint.
I was seeing what I could do to create pages a little more useful than you get using vanilla SharePoint without having to crack open Visual Studio. One of the things I wanted to do was display a SharePoint list on the screen and add a filter to the screen that would allow a user to filter the list with a date field value greater than or equal to whatever a user entered. Sound’s simple right?
Hopefully all of this wasn’t too confusing – it’s a hard formula to decipher, but as with all formulas, the best approach is to break it into chunks, determine what each chunk does independently, then merge them all back together and run through the entire thing with a series of test data.
In the next part of this series, we’ll be wrapping things up with a quick revisit to our (now more understandable) formula, and summary.