on 03-26-2013 7:29 AM
Hi,
Please can you tell me how can i determine the week for a particular month,starting from Sunday.
I have written script in HANA as :
SELECT WEEK(TO_DATE ('2013-03-01', 'YYYY-MM-DD'))
- WEEK(ADD_DAYS(TO_DATE ('2013-03-01', 'YYYY-MM-DD'),-(DAYOFMONTH(TO_DATE ('2013-03-01', 'YYYY-MM-DD'))-1)))+1 FROM DUMMY;
But it doesn't seem accurate, it fails for date 2013-03-31, as the week number should be 6.
in SQL similar functionality is achieved by (for week starting from Monday):
link for SQL code : http://think-robot.com/2009/04/week-of-the-month-in-mysql/
Please help!
Regards
Sushant
Hi Sushant,
You can use option "Generate Time Data" found on Help -> Quick Launch view
Choose: Gregorian type, Year from and to, Granularity (day), First day of the week = SUNDAY
This will populate table _SYS_BI.M_TIME_DIMENSION
Link your table with this one joining with Date (see on table that you have type DATE_SAP or DATE_SQL) and look for field WEEK.
Regards, Fernando Da Rós
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushanth ,
i'm also getting the same error while executing the PAL Algorithm.
could not execute 'CALL palLR(MLR_DATA_TAB, "#MLR_CONTROL_TAB", MLR_RESULTS_TAB, MLR_FITTED_TAB, MLR_SIGNIFICANCE_TAB, ...' in 379 ms 845 µs .
SAP DBTech JDBC: [2048]: column store error: search table error: [2620] executor: plan operation failed;required data for execution not found .
Can you please suggest me the solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushant,
for different timezone support (which is basically, what you're asking here), please check SAP note https://service.sap.com/sap/support/notes/1791342.
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravindra,
I have a requirement which is explained below. How i should get in hana sql.
Requirement -- 1) get the first day of week. 2) get the last day of week.
Example -- If today's date is 15/08/2013 THEN first day of week should be 11/08/2013
If today's date is 15/08/2013 THEN last day of week should be 17/08/2013
In Oracle we can achieve it by writing below query. But how i should get in hana sql. ? please reply . U can mail me to @ amitmbit@gmail.com
-First day of current week(sunday)
select TRUNC(SYSDATE, 'Day') from dual;
--Last day of current week(sunday)
select TRUNC(SYSDATE, 'Day')+6 from dual;
Hi Amit,
Ideally you should have opened a new discussion thread. You can use ADD_DAYS function to achieve your requirement.
select to_date('15-08-2013', 'dd-mm-yyyy'),
weekday(to_date('15-08-2013', 'dd-mm-yyyy')),
add_days(to_date('15-08-2013', 'dd-mm-yyyy'), ((weekday(to_date('15-08-2013', 'dd-mm-yyyy')) + 1) * -1)) as "WEEK_FIRST_DAY"
from dummy
Regards,
Ravi
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.