Results 1 to 4 of 4

Thread: Run Parameter within Date Subtract Node

  1. #1
    Contributor
    Join Date
    Apr 2013
    Location
    Warrington
    Posts
    15

    Default Run Parameter within Date Subtract Node

    hi - am using the above node but wish to pass in todays date as a parameter as opposed to using a date passed as an input parameter.

    I tried setting a run parameter with date = today() and inserting this within the calculation field on the node but the node errors.

    Is there a simpler way to do this? If at all possible.

    the scenario i am working with is calculating the number of days since a phone call was made by a CLI with input field of call_date.

    thanks

    Martin

  2. #2
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    232

    Default

    Why not just put a Filter node in front of the Date Subtract accelerator node and create a field that contains today's date, and then use that field as the reference date, e.g.

    emit *, date() as "RefDate"

    Here is an example of using it in a data flow:

    Code:
    node:Dummy_Input
    bretype:core::Dummy Input
    editor:sortkey=5a1592516c6b4990
    output:@40fd2c7452fa204a/=
    prop:Header=Rec_ID
    prop:NumberOfRecords=30
    editor:XY=270,140
    end:Dummy_Input
    
    node:Create_some_dates
    bretype:core::Filter
    editor:Label=Create some dates
    editor:sortkey=5a15926e053017c3
    input:@40fd2c74167f1ca2/=Dummy_Input.40fd2c7452fa204a
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    if firstExec then {
    	StartDay = dateAdjust(date(), -2, "months")
    	theDay = StartDay
    }
    
    
    emit recordNumber() as "Rec_ID", theDay
    
    theDay = theDay.dateAdjust(2, "days")
    
    EOX
    editor:XY=380,140
    end:Create_some_dates
    
    node:Set_RefDate_as_today
    bretype:core::Filter
    editor:Label=Set RefDate as today
    editor:sortkey=5a159ee529007cd1
    input:@40fd2c74167f1ca2/=Create_some_dates.40fd2c7420761db6
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    
    emit *, date() as "RefDate"
    
    EOX
    editor:XY=510,140
    end:Set_RefDate_as_today
    
    node:Date_Subtract
    bretype:accelerators::Date Subtract
    editor:sortkey=5a1593d852a557e0
    input:@55bf319320254189/=Set_RefDate_as_today.40fd2c7420761db6
    output:@55bf31930af57655/=
    inclockxy:Inclock=20,30
    outclockxy:Outclock=400,30
    prop:CalculationDate=RefDate
    prop:DateField=theDay
    editor:XY=620,140
    node:Perform_Date_Subtract_Calculation
    bretype:::Perform Date Subtract Calculation
    editor:shadow=56b0ca0b14062b7c
    input:@40fd2c74167f1ca2/=
    output:@40fd2c7420761db6/=
    end:Perform_Date_Subtract_Calculation
    
    node:Perform_Date_Subtract_Calculation_2
    bretype:::Perform Date Subtract Calculation
    editor:shadow=56b0ca0b34fb16c7
    input:@40fd2c74167f1ca2/=
    output:@40fd2c7420761db6/=
    end:Perform_Date_Subtract_Calculation_2
    
    node:Create_New_Field_Name
    bretype:::Create New Field Name
    editor:shadow=56b0ca0b6cbb5647
    output:@40fe6c55598828e5/=
    end:Create_New_Field_Name
    
    node:Apply_Field_Name_Changes
    bretype:::Apply Field Name Changes
    editor:shadow=56b0ca0b7f201d0b
    input:@516511412c32051f/=
    input:@5162dc5f486743e5/=
    output:@51778acf012c236e/=
    output:@5163cf7b3f3e218f/=
    end:Apply_Field_Name_Changes
    
    node:Bypass
    bretype:::Bypass
    editor:shadow=56b0ca0b5f15560a
    input:@55bf41e9040e0e89/=
    input:@55bf41eb58c41183/=
    output:@40fd2c7436717256/=
    end:Bypass
    
    end:Date_Subtract

  3. #3
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    232

    Default

    BTW the built-in property for the today's date is {{^CurrentDate^}}

    If you wanted to create a date type field containing today's date you could use the following script in a Filter node

    emit date("{{^CurrentDate^}}", "CCYY-MM-DD") as "today"

  4. #4
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    232

    Default

    If you use {{^CurrentDate^}} as the 'CalculationDate' property and set the 'UseAnotherField' property to False then the Date Subtract node will work.

    However, I would not recommend this approach as it means the field containing the number of days difference will have a different field name each day it is run,
    i.e. the field would be called:
    Days_Between_theDay_And_2017-11-22

    where the suffix (2017-11-22) would change to align with the current run date.

    If you configure the node to compare the date against another input field the output field name would be called:
    Days_Between_theDay_And_RefDate

    (or, if you used the second method described above)
    Days_Between_theDay_And_today

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •