Hi Gurus,
I am trying to write a build-op(first time) in C++ for some business transformations. One of the requirements is, I am getting date from a flat file in the format mm/dd/yyyy and the requirement is to load the target with mm/01/yyyy. Can anybody suggest a way to do this in the build-op. If possible please let me know how should I do this using datastage also.
Thanks for your time
replace mm/dd/yyyy with mm/01/yyyy
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
I am guru , but the following messages might become a token for you to break the ice...
You may not need the BuildOp since it is usually used to build a customed stage for your designer. To achieve this date transformation, you just need to create a PX routine using c code. There is a sample folder in DS CD, you shall find the clue to complete the job..
Cheers!
You may not need the BuildOp since it is usually used to build a customed stage for your designer. To achieve this date transformation, you just need to create a PX routine using c code. There is a sample folder in DS CD, you shall find the clue to complete the job..
Cheers!
Hello Accord,
this operation is not difficult in either Px or Server and you do not need to do any c++ or other coding to effect it.
In a transform just specify In.InDate[1,3]:'00':In.InDate[6,5] in both flavors to get the required format.
this operation is not difficult in either Px or Server and you do not need to do any c++ or other coding to effect it.
In a transform just specify In.InDate[1,3]:'00':In.InDate[6,5] in both flavors to get the required format.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
Try this:
I am sure there are many ways to do what you're looking for, but this works.
Code: Select all
// First, load input date string into a date variable
APT_Date tmpDate1;
tmpDate1.set(in.dtfromfile, "%mm/%dd/%yyyy");
// Then, create new temp variable using Y and M pieces of first date,
// and 1 for day. The class APT_Date has a constructor that we can
// use: APT_Date(int year, int month, int day). Also, APT_Date has functions for returning pieces of the date.
APT_Date tmpDate2(tmpDate1.year(), tmpDate1.month(), 1);
// Finally, assign your output date field
out.outputDate = tmpDate2;
// ... or your output string field
out.outputDateString = tmpDate2.asString("%mm/%dd/%yyyy");
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
Thank you very much.That is working....
bcarlson wrote:Try this:
I am sure there are many ways to do what you're looking for, but this works.Code: Select all
// First, load input date string into a date variable APT_Date tmpDate1; tmpDate1.set(in.dtfromfile, "%mm/%dd/%yyyy"); // Then, create new temp variable using Y and M pieces of first date, // and 1 for day. The class APT_Date has a constructor that we can // use: APT_Date(int year, int month, int day). Also, APT_Date has functions for returning pieces of the date. APT_Date tmpDate2(tmpDate1.year(), tmpDate1.month(), 1); // Finally, assign your output date field out.outputDate = tmpDate2; // ... or your output string field out.outputDateString = tmpDate2.asString("%mm/%dd/%yyyy");