on 09-25-2008 11:28 AM
Hi.
Problem: I need to get the previous month last day, no matter which date I open the report.
Example 1: I run the report on the 13th February 2008, and I want the report give me the last date of the previous month, in this example: 31th January 2008.
Example 2: I run the report on the 1st February 2008, and I still get 31th January 2008.
I have several calendar dimensions to use:
Date (numeric), Day (numeric), Month (numeric), Monthname (text).
I hope this is possible to do without altering the universe or write SQL in hand. Thanks in advance!
Andy,
Here is the WebI code to take a date and make it represent as the last day of the month prior to that date:
=RelativeDate(ToDate("01/"+FormatDate([Andy Date];"MM")+"/"+FormatDate([Andy Date];"yy");"dd/MM/yyyy");-1)
Here are some notes working inside out:
- Using [Andy Date] extract the month and year portion, then force that to a new date-type using the first day of the month (todate("01/"+(month of Andy Date) "/" (year of Andy Date);"dd/MM/yyyy")
- use RelativeDate to take the new date and give the minus 1 (substract) argument
Hope this works out for you. I did some testing on my end and was satisfied with the results, but more often than not have worked this problem on the SQL server side versus WebI. It's good to see WebI fles its muscles sometimes too.
Thanks,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Andy,
I'm not sure what's up with the error you're getting, I would say to try to copy/paste directly into the variable editor formula portion and then substitute "Audit Start Timestamp" for your date. However, I need to provide a re-attack on the formula. Yesterday during testing I didn't notice a "problem", however, today I'm noticing that instead of getting 9/30/08 I'm getting 9/29/08. Same formula, just a different day of the month (today is Oct 3 and yesterday was Oct 2). I think that there are some inaccuracies in using RelativeDate that BusinessObjects has previously acknowledged and will be fixed in fixedpacks to 3.0 (and permanently fixed in 3.1), if my memory serves correctly (I lost a lot of my tech support notes for my BO account back in July when SDN took over the Tech Support Web pages -- nothing was ever transferred from the BO legacy support system for individuals like me, pretty sad, and sadder that I didn't keep my own running history, but now I've learned).
Anyhow, RelativeDate doesn't calculate properly as it seems to compute based on minute ticks versus "day" ticks, so we need to pile another function on to the formula -- LastDayOfMonth.
Here is an updated version that should work for you:
=LastDayOfMonth(RelativeDate(ToDate("01/"+FormatDate([Audit Start Timestamp];"MM")+"/"+FormatDate([Audit Start Timestamp];"yy");"dd/MM/yyyy");-1))
Thanks,
John
Hi,
Hope you can use the Relative Date() and
LastdayofMonth()..
Regards
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had hoped I could to something matematicly like this:
I would want to solve it something like this (ill use March (3) as an example):
Take month number (3 for march) - and add 11 = 14
When number value is higher than 12, then substract 12 to the total. 14 - 12 = 2 (February)
Another example:
January (1) + 11 = 12. (Since 11 is not above 12, its not substracted by 12.)
February (2) + 11 = 13 (whis is above 12, therefore substract 12) = 1.
I still get errors. (Invalid identifier 'Date' at position 1. (Error: WIS 10022))
Now I tried using only measures I created myself.
I created a measure called Date, which look like this:
=CurrentDate()
I then pull in the measure and modify the string to the sugested, and then I get this error: (Invalid identifier 'Date' at position 1. (Error: WIS 10022)).
Would it be possible to create the function from scratch, not using any Dimensions, measures and such...?
Andy,
Do you want to get the previous month last day on WebI or SQL Server? In SQL server you'll have to parse the current-date (getdate()) to make it look like mm'/''01''/'yyyy - 1 (that is the month, an arbitrary day of 01, the year, then substract all of that by 1 (1 day) and you should be home free.
Thanks,
John
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.