Is there a way to define the weekly period I would like to use on a report, Currently Access has the week defined as sun through sat, I would like to use mon through sun.
The Weekday function has an optional parameter to define the start day - is that any use?
Related
I have a Dynamics CRM SSRS report which has two date parameters to filter records when report is executed.
When running the report I would like the parameters to default to the current financial year eg. if today is 01/10/2017 then From should default to 01/04/2016 and To should default to 31/03/2017.
Can this be done and if so what is the best way?
Not sure why people are over complicating this. I understand the common need for date tables, I use them a lot but it's pretty easy to do in an expression.
The From date expression needs to be
=DATESERIAL(Year(Now()) - (IIF(format(now(),"MMdd") > "0331",0,1)) ,4,1)
and the to date expression needs to be
=DATESERIAL(Year(Now()) + (IIF(format(now(),"MMdd") > "0331",1,0)) ,3,31)
All we are doing is creating a date value that is either 1st April current year or 31st March current year then depending on if the current date is on or before the 31st March we adjust the year by 1.
I'M ASSUMING YOUR DATES ARE WRONG IN YOUR EXAMPLE. You said you wanted current financial year but your sample showed last financial year. Anyway, if the code above is incorrect just adjust the Year(Now()) to be (Year(Now())-1) .
Im having problems with this.
I have this qlikview script which is run on the 15th of every month. This script intends to automatically take the last date of the previous month in the format of 'YYYY-MM-DD'.
For example today is 15th January 2017. I will run my script and it will give me a date of 31th December 2016 in the format 2016-12-31.
If it is 15th December 2016, I will get 30th November 2016 in the format 2016-11-30.
I want to set the date retrieved as a variable in the format yyyy-mm-dd to be used in another query.
Basically I tried
SET #vLastDate = DATE_FORMAT(select last_day(curdate() - INTERVAL 1 MONTH), '%Y-%m-%d');
but I receive an error that it does not execute. I am doing this in qlikview. Please help me identify my problem thank you.
You are trying to execute mysql functions in qlikview? That won't work.
Try in QV script:
let vLastDate = MonthEnd(AddMonths(Today(),-1));
If you need to change the date format, play around with the Date#() function, probably something like Date#(Field, 'YYYY-MM-DD'). Today() returns YYYY-MM-DD format so it will probably be fine.
I need some help. I want to get the week number of a specific date with the following system:
The week containing January 1st is the first week of the year. The week begins on Sunday. Range 1-53.
For example:
- Week 1 of 2015 begins on Sun 12/28/14 and ends on Sat 01/03/15.
- Week 1 of 2016 begins on Sun 12/27/15 and ends on Sat 01/02/15.
- Week 1 of 2017 begins on Sun 01/01/17 and ends on Sat 07/01/17.
I have read the WEEK(date[,mode]) function documentation, but none of these 'modes' match with my requirements.
How can I achieve this?
You can probably get this by using the DAYOFWEEK function. It will return you the value of what the day is (1-7 where 1 is Sunday, etc). From there, you can determine when the week has started and when it will end.
You have the WEEKOFYEAR as well. Please go thru manual
I was having the same problem, the function YEARWEEK solved it for me
SELECT YEARWEEK("2016-01-01");
>> 201552
I'm having a bit of trouble currently. The system I'm trying to implement is a 'callback' system that will set callbacks against customers that will pop up on the system at the specified date.
One of the features is a reoccurring callback. The two options are monthly and yearly. I have the yearly ones working fine:
SELECT * FROM `callbacks` WHERE (
-- Yearly Callbacks
(DAYOFYEAR(`date_callback`) = DAYOFYEAR(NOW()) AND `occurs` = 'yearly') OR
-- Other Callbacks For Today
(DATE(`date_callback`) = DATE(NOW())))
But I'm having trouble visualising how to check if a callback that is monthly is due. It should only occur once every 30 days in the list (that uses the above query.) I was using DAYOFMONTH but I realised that if a callback was set for the 31st it wouldn't appear in the list for a few months at a time despite it being a monthly callback.
So if one is set for March 3rd 2013 and set for montly, it should appear in the results of the query if the date is:
March 3rd 2013
April 1st 2013
May 1st 2013
May 31st 2013
June 30th 2013
and so on. Has anyone dealt with this before?
I'd consider to use interval, something like
. . .
(DATE_ADD(NOW(), INTERVAL 1 MONTH))
. . .
See also this post.
Or - you can try (pseudocode)
now() - pre_saved_date % 30 (module of 30)
For % - use MOD function, like
select MOD(2, 3);
select 3 % 2;
I have a web page with a DatePicker control (from Kendo UI) on it.
Firstly, I'm in New Zealand, which is UTC +12:00
When I select a date of 31st October 2012 in my date picker, it gets stored in the JavaScript object as:
Wed Oct 31 00:00:00 UTC+1300 2012
This seems wrong!
It gets serialized to JSON (using JSON.stringify) as 2012-10-30T11:00:00.000Z, which is wrong.
Back on the server, when the JSON is parsed, this comes out at 30th October 2012, 23:00.
Can somebody explain this to me? And what is the solution?
I have this figured out now - the date picker control is working correctly, as for the date of October 31st, New Zealand will be in Daylight Savings Time, so at that date, we will be UTC +1300.
My problem is that my server code is converting to UTC on the basis of today's date, rather than using the offset as it would be on the the actual date.