We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Convert date field from str. to datetime.Date as: 2017-12-29

Comments

3 comments

  • Avatar
    Adrian Williams

    The Modify Fields node should be able to convert string values to a date provided your data has a consistent format.

    If necessary you can give a hint to the auto detection mechanism by setting the 'AmbiguousDateResolutionMode' property to 'Day First'.

    However, if your data has an inconsistent format with leading and trailing whitespace characters then you will need to remove them first so that the data format presented to the Modify Fields node is consistent. Using the strip() operator will remove both leading and trailing whitespace. 

    The community forum already has a number of example of using the strptime function within a Transform node which can be found using the forum's Search functionality.

    However, for your situation described above I have the following comments:

    1.In Option 2 the format_str pattern is '%d/%m/%Y'  this should be '%d-%m-%Y' to align with the stated format of your data

    2. In Option 2 the date_object is defined as being a date type object. However, you have an upper-case 'D' in the metadata specification:  datetime.Date  - this should be datetime.date. Also in the ProcessRecords script the final line should be 

    0
    Comment actions Permalink
  • Avatar
    Noelle03

    The following is the solution to my problem:

    'If necessary you can give a hint to the auto detection mechanism by setting the 'AmbiguousDateResolutionMode' property to 'Day First'. 

    Thank you for your support. 

    0
    Comment actions Permalink
  • Avatar
    Joshua Campbell

    Very helpful. Thanks!

    0
    Comment actions Permalink

Please sign in to leave a comment.