How to achieve date
Moderators: chulett, rschirm, roy
How to achieve date
Hi,
I have a requirement like this I want to minus -1 day from the date .
For Ex. If I have date 99991231, I want to have 99991231-1 i.e 99991230.
how to achieve this. please help me
Thanks,
Somaraju
I have a requirement like this I want to minus -1 day from the date .
For Ex. If I have date 99991231, I want to have 99991231-1 i.e 99991230.
how to achieve this. please help me
Thanks,
Somaraju
somaraju
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Hi ray,
Thanks for reply. My requirement is I have a date with sql type char '19800412' and I want to minus one from this so I have to get '19800411' with sql type char. When I used DateFromDaysSince function.I getting an error since my requirement is with char sql type I tried like this in transformer I gave (DSLink.Validfromdate-'01') Iam getting an output as 1.99707e how to get my output as 19970701 please help me
Thanks,
Somaraju
Thanks for reply. My requirement is I have a date with sql type char '19800412' and I want to minus one from this so I have to get '19800411' with sql type char. When I used DateFromDaysSince function.I getting an error since my requirement is with char sql type I tried like this in transformer I gave (DSLink.Validfromdate-'01') Iam getting an output as 1.99707e how to get my output as 19970701 please help me
Thanks,
Somaraju
somaraju
Conver to date and use Function
Hi SomaRaj,
First you have to convert char date to date data type then use DateFromDaysSince, U will get the result.
Ex:
DateFromDaysSince(-1, StringToDate("YourdateValue","%yyyy%mm%dd"))
Rgds,
Rao.
First you have to convert char date to date data type then use DateFromDaysSince, U will get the result.
Ex:
DateFromDaysSince(-1, StringToDate("YourdateValue","%yyyy%mm%dd"))
Rgds,
Rao.
somu_june wrote:Hi ray,
Thanks for reply. My requirement is I have a date with sql type char '19800412' and I want to minus one from this so I have to get '19800411' with sql type char. When I used DateFromDaysSince function.I getting an error since my requirement is with char sql type I tried like this in transformer I gave (DSLink.Validfromdate-'01') Iam getting an output as 1.99707e how to get my output as 19970701 please help me
Thanks,
Somaraju
Re: Conver to date and use Function
Hi Rao,
Iam getting an error like this when I used your logic
APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "**********" for conversion "date=date_from_days_since[**********](int32)": APT_Conversion_Date_DaysSince: Invalid Date [**********] used for date_from_days_since type conversion.
datefromdayssince is taking int32 as input how to achieve in my case.
Thanks,
Somaraju
Iam getting an error like this when I used your logic
APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "**********" for conversion "date=date_from_days_since[**********](int32)": APT_Conversion_Date_DaysSince: Invalid Date [**********] used for date_from_days_since type conversion.
datefromdayssince is taking int32 as input how to achieve in my case.
Thanks,
Somaraju
somaraju
Somu
Your Input is Char and Output is Char again. So you need to follow the steps
1. Convert Chat to Date using StringToDate Function
2. Use DateFromDaysSince Function to the result of Step 1 to Substract 1 day from the result.
3. Convert Back your date result to Chat type again using DateToString function.
Regards
Your Input is Char and Output is Char again. So you need to follow the steps
1. Convert Chat to Date using StringToDate Function
2. Use DateFromDaysSince Function to the result of Step 1 to Substract 1 day from the result.
3. Convert Back your date result to Chat type again using DateToString function.
Regards
Regards
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Hi Rasi,
I followed the steps you said but Iam getting the same error as I mentioned above post. I think this error is because of the function datefromdayssince.I think it will take only int(32) value or Iam making a mistake in conversion that is (%yyyy%mm%dd). Correct me if Iam wrong
DateToString(DateFromDaysSince(-1,StringToDate("Frm_Src.ValidFromDate","%yyyy%mm%dd")))
Thanks,
Somaraju
I followed the steps you said but Iam getting the same error as I mentioned above post. I think this error is because of the function datefromdayssince.I think it will take only int(32) value or Iam making a mistake in conversion that is (%yyyy%mm%dd). Correct me if Iam wrong
DateToString(DateFromDaysSince(-1,StringToDate("Frm_Src.ValidFromDate","%yyyy%mm%dd")))
Thanks,
Somaraju
somaraju
Somu
I had test with your code by substuting the input to hard coded value
DateToString(DateFromDaysSince(-1,StringToDate("20060726","%yyyy%mm%dd")))
I am getting the result = 2006-07-25 which is what you would expect. Check whether your input is correct. You can cut and paste the above code in your job to see whether it gives you the correct result
I had test with your code by substuting the input to hard coded value
DateToString(DateFromDaysSince(-1,StringToDate("20060726","%yyyy%mm%dd")))
I am getting the result = 2006-07-25 which is what you would expect. Check whether your input is correct. You can cut and paste the above code in your job to see whether it gives you the correct result
Regards
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Siva
Listening to the Learned
"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
-
- Charter Member
- Posts: 166
- Joined: Wed Mar 16, 2005 6:52 am
- Location: Mumbai, India
Re: Conver to date and use Function
This happens when the StringToDate fails to parse a date using the provided pattern.somu_june wrote:Hi Rao,
Iam getting an error like this when I used your logic
APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "**********" for conversion "date=date_from_days_since[**********](int32)": APT_Conversion_Date_DaysSince: Invalid Date [**********] used for date_from_days_since type conversion.
datefromdayssince is taking int32 as input how to achieve in my case.
Thanks,
Somaraju
To test why,
In the transformer, split this step into 2 seperate stage variable derivations:
1. ConvertedDate(DATE)<-- StringToDate(<IN.Date>,"%yyyy%mm%dd")
2. and the subtracted value using If isValid(ConvertedDate) then Subtract Value else 0.
Add another output link to the transformer that writes to a reject sequential file(Or a peek stage.. but I prefer Sequential Files) to capture the rows and values for which this conversion fails.
IHTH
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
Re: Conver to date and use Function
Hi,
Thanks for every one. My problem was solved why Iam getting that error is my output is char(8 and when I used rasi steps I got my output as 2006-07-26 but I want as 20060726 so I coded like this to achieve my target
DateToString(DateFromDaysSince(-1,StringToDate(Dslink.Validfromdate,"%yyyy%mm%dd")),"%yyy%mm%dd")
Thanks,
Somaraju
Thanks for every one. My problem was solved why Iam getting that error is my output is char(8 and when I used rasi steps I got my output as 2006-07-26 but I want as 20060726 so I coded like this to achieve my target
DateToString(DateFromDaysSince(-1,StringToDate(Dslink.Validfromdate,"%yyyy%mm%dd")),"%yyy%mm%dd")
Thanks,
Somaraju
somaraju