DATEADD(month, -1, getdate()) This is the function in SQL server which gives timestamp corresponding to last month. Now I want to implement the same logic in one of the columns for transformer. I have tried serveral predefined options of datetime and current timestamp functions in transformer which are not giving last month date.. Can some one help me getting this logic. The date should correspond to currentdate minus one month.
Thanks in advance
Ranjan Mahapatra
get lastmonth timestamp in transformer
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 15
- Joined: Mon Apr 23, 2012 12:28 pm
get lastmonth timestamp in transformer
Last edited by smile.achieve on Mon Jun 11, 2012 7:39 am, edited 1 time in total.
Your example looks wrong for the description posted... -11 months?
It would probably be helpful to know what you've tried already, for example did you give DateFromDaysSince() a try? Granted you'd have to use 30 or 31 for the number of days in a month, but it would get you... close.
I'd also be curious what the rules are for dates that don't exist in the previous month - for example, what would March 31st minus one month equal?
It would probably be helpful to know what you've tried already, for example did you give DateFromDaysSince() a try? Granted you'd have to use 30 or 31 for the number of days in a month, but it would get you... close.
I'd also be curious what the rules are for dates that don't exist in the previous month - for example, what would March 31st minus one month equal?
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Your edit has removed the example, leaving us even more in the dark.
At a guess, I'd say what you need to do is subtract the number of days in the previous month from the current date.
At a guess, I'd say what you need to do is subtract the number of days in the previous month from the current date.
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: 15
- Joined: Mon Apr 23, 2012 12:28 pm
No. Ray i dont see any issues with the example now. If you are aware of datedadd() function of sqlserver may be you will be able to get a clear picture. However i tried solving this by getting the month number first and subtracting 30/31 days based on the month number(got from MonthFromdate()).How ever my code does not give valid results for following dates. 30th March,31st March.To handle this is seperate if else clause i need to get some function like DayfromDate() which is not available.
Smile