locked
Adding Today Date using Designer RRS feed

  • Question

  • Hi

    I have been at this for weeks and have still not found any answers. I am trying to add a date to a holding column in sharepoint and I want that date to be always the current date. I see it is quite a difficult thing to figure out and I have also been trying to learn SP designer as well. Our list is a default datasheet view and I want to keep it like that.

    Is it possible to go into insert > asp.net controls and add a text box with the current date using some sort odf code or whatever? I am totally new to this and am walking through a thick forest with no compass and it is getting dark so if anyone has any knowledge about how to add this column with current date please can you share this?

    The problem is I cannot seem to add a text box or column to the datasheet list it is just adding it to the main page. When I went to insert > sharepoint controls it changed the datasheet view to like a new item form and I had to delete and recreate the view/list as I could not revert it. This is not what I want, how can I manipulate individual columns but keep the datasheet view?

     

    Thanks

     

    V


    Andrew (MCDST)


    • Edited by VBDevNewbie Thursday, January 5, 2012 11:47 AM
    • Edited by Mike Walsh FIN Thursday, January 5, 2012 11:56 AM The word "urgently" has no place in forum posts. If you are in a hurry pay for support by ringing MS customer support services
    • Moved by Mike Walsh FIN Thursday, January 5, 2012 11:56 AM "using designer" (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    Thursday, January 5, 2012 11:44 AM

Answers

  • Hi Andrew,

     

    You can achieve this with calculated field.

     

    By default, we cannot use “Today” in calculated column’s formula. But here is a workaround to use “Today” function.

     

    1.         First, create a new column in your list with the Column Name of "Today".  Click "OK".  (It doesn't matter what type of column or data it is, this is just a place holder).

    2.         Next, create a column with the data where you would like to use "Today" as a reference to today’s date.  The column type should be "Calculated".  In the formula field, just type Today or double click Today from the Insert Column section

    3.         SharePoint will calculate the formula based on the assumption that you will be using "Today" as a reference to the new column you just created.

    4.         Next, edit the new column named "Today" that you created in the first step.   On the very bottom of the page, click "Delete", to delete the column.  In your formula, SharePoint will keep the reference to "Today" but it will change from referencing your column, to a reference to the current date.

     

    Now, the calculated would show current date all the time

     

    Thanks.

     


    Pengyu Zhao

    TechNet Community Support

    • Marked as answer by Pengyu Zhao Sunday, January 15, 2012 9:48 AM
    Thursday, January 12, 2012 8:32 AM

All replies

  • I'm not 100% sure what you mean here, it could be one of two things.

    Do you want a date field that is defaulted to the current date, so that when a new item is created the current date is in that field by default. But if you look back at older items the field will show whatever value was there when the item was created?

    Or do you want a field that always shows the current date no matter what, so that if you look back at older items, it still actually shows the current date?

     

    The first option is quite easy. It's something set in the definition of the field itself, and you don't need SharePoint Deisgner to do it. You just need to go to your list/library. From the "Settings" menu go to the "List/Library Settings". At the bottom of the page you should see all of the field for your list. Just click on the one you want to change to see it's definition. near the bottom of the definition screen is a section for default values. Just choose the default value to be "Todays Date", press Ok and you're done.

    The second option isn't really possible, out of the box anyway.

    Thursday, January 5, 2012 3:07 PM
  • Hi yes it is the second option, can I do this in the sharepoint designer?

    I opened site in SP designer in datasheet view but can't find any way to edit the fields in the web part.

    VB


    Andrew (MCDST)
    Thursday, January 5, 2012 5:08 PM
  • Hi Andrew,

     

    You can achieve this with calculated field.

     

    By default, we cannot use “Today” in calculated column’s formula. But here is a workaround to use “Today” function.

     

    1.         First, create a new column in your list with the Column Name of "Today".  Click "OK".  (It doesn't matter what type of column or data it is, this is just a place holder).

    2.         Next, create a column with the data where you would like to use "Today" as a reference to today’s date.  The column type should be "Calculated".  In the formula field, just type Today or double click Today from the Insert Column section

    3.         SharePoint will calculate the formula based on the assumption that you will be using "Today" as a reference to the new column you just created.

    4.         Next, edit the new column named "Today" that you created in the first step.   On the very bottom of the page, click "Delete", to delete the column.  In your formula, SharePoint will keep the reference to "Today" but it will change from referencing your column, to a reference to the current date.

     

    Now, the calculated would show current date all the time

     

    Thanks.

     


    Pengyu Zhao

    TechNet Community Support

    • Marked as answer by Pengyu Zhao Sunday, January 15, 2012 9:48 AM
    Thursday, January 12, 2012 8:32 AM
  • It may be a little late for you but, anyways! In SharePoint Designer add a new "Formula Column". The select Today. The code in the column (XSLT) would look like this:

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

    I hope this helps.

    EM

    Tuesday, March 12, 2013 12:46 PM
  • Thanks a  lot ,

    This actually work as we are able to calculate depreciation value through this help.

    Wish you a great success ,

    Thursday, October 3, 2013 11:00 AM