Data360 Analyze

 View Only
  • 1.  Python Transform from DateTime to Date

    Employee
    Posted 12-20-2017 10:54

    Hello. I am using 3.1.7 and I need to take a datetime field and transform it to a date field. 

    I tried the strftime but that won't work. I'm trying to filter by date and in 3.1.7 there may be a bug because it lets me choose the two dates from that datetime field but then gives me an error. 

    I can't filter by date if I change the date to a string because I don't get the calendar.

    Any thoughts or suggestions?

     

     

     

     



  • 2.  RE: Python Transform from DateTime to Date

    Employee
    Posted 01-02-2018 07:17

    Hi Nancy,

    can you clarify what you are trying to achieve?

    If you just want to filter the input records where the value of a datetime field is before or after a particular datetime then you can just use the Filter node. For example, using the 'create' field in the default data of the Create Data node as the field to be examined you could configure the Filter node as follows:

     



  • 3.  RE: Python Transform from DateTime to Date

    Employee
    Posted 01-02-2018 07:57

    If you want to extract the date component of a datetime field [for example the 'create' field in the Create Data default data] and output it as a date type field then you could use a Transform node and configure the ConfigureFields property as follows (excluding the [Code]..[/Code] delimiters:

    [Code]

    #Configure all fields from input 'in1' to be mapped
    #to the corresponding fields on the output 'out1'
    out1 += in1

    ## Define new output metadata for a date type field
    out1.dateValue = datetime.date

    [/Code]

     

    Then configure the ProcessRecords script as follows:

    [Code]

    #Copy all fields from input 'in1' to the corresponding output fields
    #in output 'out1'. Copies the values of the fields that have been setup
    #in the mapping defined in the ConfigureFields property
    out1 += in1

    if fields.create is Null:
      out1.dateValue = Null
    else:
      out1.dateValue = fields.create.date()

    [/Code]

     

    Note that you have to explicitly handle any Null values in the input data else the node will fail.



  • 4.  RE: Python Transform from DateTime to Date

    Employee
    Posted 01-05-2018 02:13

    I have posted a community custom node here that provides a generic mechanism to extract the date element of a datetime field.

     



  • 5.  RE: Python Transform from DateTime to Date

    Employee
    Posted 03-27-2018 21:45

    Hi Adrian

    Would you need to go into and edit the filter each time you want to change the date range.Is there away to enter the date range without having to edit the filter each time (e.g like using user input box)?



  • 6.  RE: Python Transform from DateTime to Date

    Employee
    Posted 03-28-2018 08:02

    A node must be configured before it is run. If you want to use a form-based approach the Filter node can be configured with an 'After' filter criterion and a 'Before' filter criterion to select records where the date is between the two threshold dates:

    If you want to specify property values that can be used by multiple nodes within a data flow see the Advanced section of the help that discusses paramterization using data flow properties and run properties. The online version of this topic is here:

    https://d3sa-preview.infogixsaas.com/docs/dist/help/Default.htm#d-advanced-topics/using-derived-property-values.htm%3FTocPath%3DAdvanced%2520topics%7C_____4

    [Edit: ^ Updated URL]

     



  • 7.  RE: Python Transform from DateTime to Date

    Employee
    Posted 03-20-2019 05:36

    Data3Sixty Analyze v.3.2.7 introduced the Modify Fields node which allows you to modify field metadata without scripting.

    You can now use this node to convert a datetime type field to a date type.