Complex Date Conversion Problem
Moderators: chulett, rschirm, roy
Complex Date Conversion Problem
Hi guys,
I've got a problem with converting dates in either a Column Import or Transformer that I hope someone will be able to help me out with.
The input date string is %dd %mmm and I need to convert this to a Date type using a second date as the cut off period. My initial thought was to get the year from the cut off date and append it to the source string to get %dd %mmm %yyyy. This doesn't work as I need to check if the source %dd %mmm is before the cut off period, in which case the appended year would be one year lower than that of the cut off date.
I also though that I could append the the cut off year to the source date and then convert is to a Date. This date would not be correct, but I could use it to check if it was before or after the cut off date. If before, then I use the cut off year-1. However, I think this would cause conversion errors when if the date was 29 Feb because this is only valid on a leap year.
I hope that make sense. Any help would be appreciated.
I've got a problem with converting dates in either a Column Import or Transformer that I hope someone will be able to help me out with.
The input date string is %dd %mmm and I need to convert this to a Date type using a second date as the cut off period. My initial thought was to get the year from the cut off date and append it to the source string to get %dd %mmm %yyyy. This doesn't work as I need to check if the source %dd %mmm is before the cut off period, in which case the appended year would be one year lower than that of the cut off date.
I also though that I could append the the cut off year to the source date and then convert is to a Date. This date would not be correct, but I could use it to check if it was before or after the cut off date. If before, then I use the cut off year-1. However, I think this would cause conversion errors when if the date was 29 Feb because this is only valid on a leap year.
I hope that make sense. Any help would be appreciated.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
First please make clear whether this is a server job question (as marked) or a parallel job question (as per the forum in which you have posted). The answer will be markedly different based on job type. If it's in a job sequence, let us know that too.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Convert your InDate and CutOffDate to this format - %mm%dd (mmdd - string). Now follow the below logic in stage variable:
If MMDD of InDate is greater or equal to MMDD of CutOffDate then append CCYY else append CCYY - 1
If MMDD of InDate is greater or equal to MMDD of CutOffDate then append CCYY else append CCYY - 1
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
You have to convert %mm%dd (mmdd - string). Other way it will be wrong results.
bmsq wrote:...the conversion from %dd %mmm to %dd %mm..
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Try StringToDate function
Ex:
StringToDate('Mar 02 2003',"%mmm %dd %yyyy")
Will give you - "2003-03-02"
For the year part you can append a dummy year to your InDate field.
Ex:
StringToDate('Mar 02 2003',"%mmm %dd %yyyy")
Will give you - "2003-03-02"
For the year part you can append a dummy year to your InDate field.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Missed that point. You have to use a leap year to ensure "29 Feb" is valid.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>