Convert Text to Date ad update field

Forums Dynamic Forms for SharePoint Convert Text to Date ad update field

This topic contains 3 replies, has 2 voices, and was last updated by  Alexander Bautz 4 months, 2 weeks ago.

  • Author
    Posts
  • #16651

    Phil Meacham
    Participant

    I have two lists, a timeline list and a task list, both are task content types.

    I use vLookup so that I can associate the tasks to the timeline.

    On the task list, when you create a new item, I have cascading drop downs to select the related timeline. So you select category and then the task.

    Once you have this, it then pulls in the Due Date of the related timeline.

    I then want to store this due date as a Date column, using a rule.

    The problem I have, when I pull the due date into the text field, it’s formatted as “2017-09-18 00:00:00” for example.

    I need to then somehow, convert this to a date so that I can do a comparison and ensure that a task due date isn’t being made that is beyond the due date of the milestone.

    Does anyone have any idea how I might achieve this or how I can convert the text date format to a normal date format so I can then run the comparison.

    Thanks in advance!!

    Phil

  • #16749

    Alexander Bautz
    Keymaster

    Hi,
    I’m sorry for not replying earlier. You find a function in DFFS that converts this “ISO8601” formatted string to a proper date object:

    var date = spjs.dffs.iso8601ToObj("2017-09-18 00:00:00");

    Alexander

  • #16790

    Phil Meacham
    Participant

    Thanks for this Alexander, how do I put this in to the form though? Do I do it in the value part of the rules section?

  • #16804

    Alexander Bautz
    Keymaster

    Sorry, I thought you already used custom js and could use this snippet to convert it.

    If you use a rule to write the date from the cascading dropdown field and to the date field you could try using a calculated column as source of the cascading dropdown (to have the format correct from the start). Set the formula of the calculated column like this:

    =TEXT("Due date","MM/dd/yyyy")

    Change the “MM/dd/yyyy” to match your date format.

    Alexander

You must be logged in to reply to this topic.