I was able to figure this out and realized that I needed to format it as such - '||attributename||'.
Original Message:
Sent: 09-07-2023 10:02
From: Brittany Adams
Subject: Date - Date Type Attribute Manipulation
Hello Brian,
Thank you for your response. This feedback is very helpful. I started working on a Change Notification update using the CN_External_Attributes_SQL field. I think this option will work for what we are trying to implement. I am able to get the new date field updated using this code
SELECT DATEADD(day, 7, '2023-09-01') AS DaysAdded from Item_Staging
However, I don't want to hardcode the date in, I want to pull the date from another attribute that the user would input a date into (attribute name 'Manual Date Added') for example. Do you have any suggestions on how I could manipulate the code to pull in that date from the field and not a hardcoded date?
Thank you,
Brittany
------------------------------
Brittany Adams
DAS Companies
Original Message:
Sent: 09-07-2023 02:10
From: Brian Zupke
Subject: Date - Date Type Attribute Manipulation
Brittany,
VTL comes with some Classes including DateTool, which includes methods to convert a String to a date (using a specified format). The set of classes can be found at the following URL: https://velocity.apache.org/tools/1.4/javadoc/org/apache/velocity/tools/generic/package-summary.html
Using VTL to calculate new dates is effective when there is a data change that can drive the VTL being executed. Change Notification (and Transformation) can also be used and the calculations and formatting performed in SQL. With a CN_Registry rule, the CN_External_Attributes_SQL attribute can be used to define a SQL SELECT query (or a call to a stored procedure) that calculates a new value and then the Update configuration set the desired attributes to the calculated values. To avoid always executing the SQL for each event, a CN_Transformation_Registry rule can be defined that has the CN_Target_SQL defined that invokes the SELECT query or stored procedure that returns columns for each calculated attribute in the query or stored procedure results. There are numerous EnterWorks Tech Talk recordings on the Precisely University covering all aspects of Change Notification.
If the calculated attributes are time driven, meaning each day new values may need to be calculated for some records, then the simplest way to accomplish this is to create a View (SQL) Scheduled Export that calculates the new values for all records requiring them and generating an update file that is then fed to a Scheduled Import to update those records in the same repository.
If you are looking to use these special calculations to drive actual Scheduled jobs, you can use the Export/Import technique to calculate the next appropriate day and time for a job to run (assuming that built-in schedule options cannot produce the desired result). The EnterWorks Tech Talk ETT-145 - How to Set up Complex Schedules for Scheduled Jobs shows how to accomplish this.
------------------------------
Brian Zupke
Precisely Software Inc.
Original Message:
Sent: 09-06-2023 14:53
From: Brittany Adams
Subject: Date - Date Type Attribute Manipulation
Hello Vijay,
I am looking to update the above VTL code in our system. Instead of adding days to the current date, we would like to add the same amount of days to various dates that are input into the system. Essentially we would like to start a product life cycle tracker and populate dates in fields to show the various milestones we'd like to hit (i.e. every 30 days, the date for the next milestone is auto-populated). Do you have any suggestions on how to complete this?
Currently, I've tested the code below that parses the date but I can only get it to work when typing in '2023-05-10T00:00:00.00' as a text field in 'MANUALDATEADDED'. While this works it is not very user friendly!
#set($str="")
#set($dt=$str.getClass().forName("java.time.LocalDateTime"))
#set($dtf=$str.getClass().forName("java.time.format.DateTimeFormatter"))
$dt.parse("${Item_Staging.MANUALDATEADDED}").plusDays(30).format($dtf.ofPattern("MM/dd/yyyy"))
$dt
#end
------------------------------
Brittany Adams
DAS Companies
Original Message:
Sent: 02-07-2023 15:20
From: Vijay Zarapala
Subject: Date - Date Type Attribute Manipulation
Original Message:
Sent: 2/7/2023 10:28:00 AM
From: Brittany Adams
Subject: RE: Date - Date Type Attribute Manipulation
Hello Vijay and Jon,
This was a great exercise as I continue to develop my VTL skills (slowly, but surely). I was able to get this to work for us, and I look forward to being able to implement it for other potential processes in the future, as well.
Thank you, both!
------------------------------
Brittany Adams | Data Management Steward
DAS Companies
Original Message:
Sent: 02-02-2023 15:19
From: Jon Varo
Subject: Date - Date Type Attribute Manipulation
I agree with Vijay. VTL is most likely the best way to go here.
Good luck!
------------------------------
Jon Varo | Manager - Master Data and PIM Teams
Fender Musical Instruments Corporation | (480) 845-5823
Original Message:
Sent: 02-01-2023 07:57
From: Brittany Adams
Subject: Date - Date Type Attribute Manipulation
Hello Vijay,
Thank you, for your suggestion! I will test this out.
------------------------------
Brittany Adams | Data Management Steward
DAS Companies
Original Message:
Sent: 01-26-2023 22:17
From: Vijay Zarapala
Subject: Date - Date Type Attribute Manipulation
Hi Brittany,
Please check if this helps:
(AssignFutureDateToAttribute is an attribute used to control which records need such assignment and which do not)
#if("${this}" == '' && "${AssignFutureDateToAttribute}" == 'YES') --------------(if NO, then no action required)
#set($str="")
#set($dt=$str.getClass().forName("java.time.LocalDateTime"))
#set($dtf=$str.getClass().forName("java.time.format.DateTimeFormatter"))
$dt.now().plusDays(90).format($dtf.ofPattern("MM/dd/yyyy"))
#else
${this}
#end
Vijay Zarapala,
MDM/PIM Expert
HD Supply (Home Depot)
6784512789
------------------------------
Vijay Zarapala | Sr Developer
HD Supply | 6788245789
Original Message:
Sent: 01-19-2023 09:40
From: Brittany Adams
Subject: Date - Date Type Attribute Manipulation
Hello!
I'm looking to see if anyone has experience with leveraging the ability to manipulate 'DATE' data type attributes. My goal is to have attribute X = a specific date and then with some process (haven't managed to determine the best course of action) add an x amount of days which would then populate as this future date on attribute Y.
So far, I've tried various VTL formulas, Change Notification - Update process, Change Notification - Transformation process but nothing viable as a result.
Any suggestions or advice would be greatly appreciated!
------------------------------
Brittany Adams | Data Management Steward
DAS Companies
------------------------------