views:

11

answers:

2

Hello, I have been reading blog after blog about displaying the current date in a sharepoint list and nothing seems to work. I do not have administrative rights to my sharepoint server but I was able to combine some java scripts and was able to display the current date (that change each day) in a custom list. My problem is that my success is only half full and I need someone's help to figure out the rest. Here it goes: 1. I created a column in my list called "DateField", I use the calculation field with ="<B></B> as the calculation 2. I created a Content Edit WebPart and use the source below:

<script type="text/javascript">
var currentTime = new Date()
var month = currentTime.getMonth()+1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var CurrentDate = month + "/"+ day + "/" + year
$(document).ready(function(){
$(".ms-vb2:contains('<B')").each(function(){
var tempB = document.createElement ("B");
tempB.style.cursor = "pointer";
tempB.innerHTML = $(this).text();
$(this).text(CurrentDate);
$(this).append(tempB);
});
});
</script>

The script works and the date changes each day but I cannot use the date for anything. For some reason it only sees the HTML tags in the field but it displays the current date in the column on the list. Can someone help me figure out how I can store the actual date in the column?

Thanks Ramon

A: 

Hello Ramon If you want to store the current date field on the column to be reused that means that you will have to modify all the items every day with today's date. Is that what do you really need ? it could be achieved with some ajax call to the web services (if you have update permissions for those items). However I don't really understand your scenario. Could you elaborate ?

Renzo
Yes, that is what I want but do I have to edit each record to get the current date each day?
rtsp94
If you want to have them as a part of the record then I believe the answer is yes, if you need it only to display then your with doing what you doing should be enough, if you manage to get access to the server to be able to deploy a solution then you should consider Moo's suggestion.I Still can't understand why you need it for, if you want to use it for web part connection then you should maybe have a look at the Date Filter web part ?
Renzo
A: 

My solution was to create a custom field type for the column, which would always return the current date (and time if needed). This produced the desired effect - the current date (and time) would be displayed on the front end, but still available for use in other fields in the back end.

A quick Google for examples (my code is two jobs behind me, and I haven't touched MOSS in 6 months) gives me http://vspug.com/nicksevens/2007/08/31/create-custom-field-types-for-sharepoint/

Good luck!

Regards

Moo

Moo

related questions