Answered Infopath Date

  • Monday, January 11, 2010 3:31 PM
     
     
    Hello!

    I take a date to the form infopath that i have in publih. This date is like : 2009-11-15 00:00:00 name start

    I want to see the date like: 15/11/2009 , if i put addDays(start, 0) it put me correctly, but when i publish like web

    when i try it they show me in the text box  #ERR?

    someone knows what it is heppening?

    Thanks

All Replies

  • Monday, January 11, 2010 7:43 PM
     
     
    Where are you getting the date from? If you have a Date Field in Infopath, you can right-click , then click date-field properties , then to the right of "Data-Type" you can click t he Format button. This provides you with options for formatting your date field.
    • Proposed As Answer by Omar Stewey Monday, January 11, 2010 7:44 PM
    • Unproposed As Answer by Mike Walsh FIN Tuesday, January 12, 2010 5:57 AM
    •  
  • Monday, January 11, 2010 9:33 PM
     
     

    Omar, don't propose your own replies answers, please.  Let us propose for you, but your answer only refers to the formatting of the InfoPath control.  When a date is published to SharePoint, the format you see is the format of the value in the XML file, not the format of what you see in the control.  It comes through as 2009-11-15 00:00:00, because that's what it is in the XML regardless of the control formatting.

    To convert from the real value to a preferred text format, he'll need to use the translate function along with substring-before.


    SharePoint Architect || My Blog
    • Marked As Answer by Mike Walsh FIN Tuesday, January 12, 2010 5:57 AM
    • Unmarked As Answer by BeaSharepoint Tuesday, January 12, 2010 2:04 PM
    •  
  • Tuesday, January 12, 2010 9:36 AM
     
     
    I don't undertands:. I will explain me better

    1. I take a date for the infopath date fields.
    2. This date i put in a tex field (type string) 2009-11-15 00:00:00(name start)
    3. The i put addDays(start, 0) in the rules and put this in another tex field or data field , because is the same , i can see 15/11/2009
    4. When i publish it put me and error

    I undertand that is because it must be like "2009-11-15", but it is possible like "15/11/2009". How i can to do it?


    Thank
  • Tuesday, January 12, 2010 10:35 AM
     
     
    I have no clue what you're saying, sorry.
    SharePoint Architect || My Blog
  • Tuesday, January 12, 2010 1:36 PM
     
     
    I have this string 2009-11-15 00:00:00, i i want that 15/11/2009. With addDays(start, 0) it works but in the publish in sharepoint mode is not working.

    How i can do that , for see in the publish mode 15/11/2009
  • Wednesday, January 13, 2010 2:21 AM
     
     

    Please change your text field’s Data Type from string to Date(date) .
    It will automatically change your string in MM/DD/YYYY format.

    Hope it helps you


    Very happy new year!
  • Wednesday, January 13, 2010 10:43 AM
     
     
    I did it , but when i publish in sharepoint don't let me see it , it give me a error
  • Wednesday, January 13, 2010 6:00 PM
     
     

    I also did it :) Maybe not exactly same as what you did.

    Below is what I have.
    My test form has a DatePicker (Date Type: Date(date), Rule: Set  a field’s value:TextBox = DatePicker Value)
    It also has a Text Box (Date Type: Date(date))

    Selected value from DatePicker goes to Text Box in MM/DD/YYYY format.

    It is working on my Dev machine. I don’t think you need addDay() to change date format so I didn’t use it on my test form.


    Very happy new year!
  • Tuesday, January 11, 2011 10:19 PM
     
     

    Hi Clayton,

    Excuse me if I'm not using this forum properly (first time) but I know you have provided answers to just about every question I've had in a fabulous, easy to understand manner, so taking the opportunity to ask you to solve this one which is similar.  I am in Australia so I need my dates in sharepoint to show as DD/MM/YYYY or similar. 

    I have an infopath form published to a document library. 

    I have used a dataview webpart from Sharepoint designer to get a subset of data based on several columns

    The date field in sharepoint only allows DD/MM/YYYY and Sharepoint designer doesn't give me that option.  Is there any way to add my regional settings to Designer?

  • Thursday, January 20, 2011 8:51 PM
     
     
    "To convert from the real value to a preferred text format, he'll need to use the translate function along with substring-before.
    I need to reformat the date returned by infopath. Could you explain your solution. I don't know where and how you use translate & substring functions.
  • Thursday, January 20, 2011 10:11 PM
     
     
    "To convert from the real value to a preferred text format, he'll need to use the translate function along with substring-before.
    I need to reformat the date returned by infopath. Could you explain your solution. I don't know where and how you use translate & substring functions.

    In the function builder when setting default values or rules when setting field values.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
  • Friday, January 21, 2011 11:23 AM
     
     

    Could this not also be a problem with the data type in the actual sharepoint library also? or does the publishing option stop you from data type mis-matches? I am sure i have the exact same problem when trying to upload a datetime to a date only field in Sharepoint.

    Maybe./..maybe not, just a thought

  • Friday, January 21, 2011 3:12 PM
     
     
    Could you give me a sample format. I've read about translate and substring before, but can't put together a syntax that works.
  • Thursday, February 24, 2011 9:58 PM
     
     Answered

    Try this:

       concat(substring(<datefieldname>, 6, 2), "/", substring(<datefieldname>, 9, 2), "/", substring(<datefieldname>, 1, 4))

    It translates 2011-2-07 to 02/07/2011.

  • Wednesday, September 14, 2011 11:47 AM
     
     

    Do this to format date filed coming from sharepoint

    1. Make your field as an expression box

    2. ExpressionBox -> Properties -> General -> DataSource. Use substring-before(@ows_Created, " "). Basically getting the date part of date time

    3. Result section -> Format As -> Date. Click on format button and set whatever format you want.

  • Tuesday, March 06, 2012 1:12 PM
     
     

    Hi BeaSharepoint,

    Is this the only date column which is in YYYY/MM/DD format? Or you have other such columns which show the Date value in the format that you require (DD/MM/YYYY) ? If this is not the only column try this :

    1) go to Site settings on the site you are working

    2) Click on Regoinal Setting under Site Administration. 

    3) Select the correct Time Zone. And click Ok.

    4) Refresh the page once and open the form. 

    Hope this helps.

    Regards

    P

  • Monday, April 02, 2012 6:30 PM
     
     

    Hi Clayton,

    I am also having issues with translating the date format.  I have a text field and the text is concat with 'EXP' along with the date from a date field.  However, it looks like EXP2012-04-01 and I'd like it to look like EXP04/01/12.  Can you help me with this? 

  • Tuesday, April 03, 2012 1:01 PM
     
     

    Nancy,

    Is it possible to get the year formatted as 'YY' rather than 'YYYY'?

  • Thursday, October 04, 2012 9:38 PM
     
     

    Hi folks - Clayton is correct (as usual) but leaves you with a little homework. Here's how I did it just now, and I'll give you the exact formula as an example. I needed a date 6 weeks from today in the proper format. 6 weeks is 42 days, so to get the correct date you need:

    addDays(today(),42)

    However this yields the XML format such as 2012-11-15. SharePoint chokes on this. Since I live in the USA, I needed month/date/year. Here's how I did it:

    concat(substring(addDays(today(),42),6,2),"/",substring(addDays(today(),42),9,2),"/",substring(addDays(today(),42),1,4))

    OK I'm doing the calculation 3 times, which isn't ideal (anybody know a better way?) -- but it works. If you wanted the day/month/year format, just change the substring locations:

    concat(substring(addDays(today(),42),9,2),"/",substring(addDays(today(),42),6,2),"/",substring(addDays(today(),42),1,4))

    Cheers!


    - Bob

  • Thursday, January 31, 2013 6:48 AM
     
     

    Try this:

       concat(substring(<datefieldname>, 6, 2), "/", substring(<datefieldname>, 9, 2), "/", substring(<datefieldname>, 1, 4))

    It translates 2011-2-07 to 02/07/2011.

    Thanks Nancy.

    It works for me.