I have here some question regarding on the above subject.
I have a parameter which is Start Date (01/01/2013)
and End Date (03/31/2013)
and a table which displays the data.
Here is my question
Can I repeat the table by month?
so if my date range is 01/01/2013 to 03/31/2013
I should have 3 tables for January - February - March
Is this possible?
Use a List control, grouped on Month Name or Month Number (or anything to designate a month), put a table within the List control to house your data for each month.
Related
I want to create a table that has two columns, date and count.
Date is basically just date since we started accepting payment until today (let's say 2021-09-01 to today).
Count represents the # of active merchants (i.e. anyone that has processed ANY transaction in the past 3 months)
I understand that in order to get the last 3 months of data from today, I need to do
created between date_add ('month', -3, current_date) and current_date
Is there a way that I can do that for every single row, so instead of using current_date, I can use the date that is in the date column?
I want to extract week from datetime, the output I want is 'YY/week', where week is the week of the year (eg '201724' is the 24th week in 2017).
The term "week of the year" is too ambiguous.
The week may start from Sunday, Monday or another weekday
The weeks enumeration in the year may start from 0 or 1
The weeks enumeration in the year may start from the week which includes January, 1 (and hence may be partial) or from first complete week of the year
The last week of the year, if it is partial, may be counted or not
Each DBMS has its own functions (sometimes original, always with original names) that can return the number of the week in the year on a given date. But they can not always take into account the above features.
Important addition provided by jarlh:
ISO 8601 (#4.3.4):
The first calendar week of a year is the one that includes the first Thursday of that year.
The last calendar week of a calendar year is the week immediately preceding the first calendar week of the next calendar year.
Week 1 is the first week of a year.
A calendar week starts on a Monday.
ISO 9075 doesn't even mention weeks.
SELECT TO_CHAR(TO_DATE('19-FEB-22') , 'IW') from DUAL;
To get the corresponding four-digit year, use
SELECT TO_CHAR(TO_DATE('19-FEB-22'), 'IYYY') FROM DUAL;
TO_CHAR() having so many options like this read more in Oracle manual or extract portation of date Extract Portion of Date Time Value
OutPut
You can use the following Mysql type query to extract.
SELECT DATE_FORMAT(BirthDate, " %u %Y") FROM Employees;
where the BirthDate date column in the database and the Employees is the table name.
This will result
49 1968
08 1952
35 1963
Week and the year.
in postgresql:
SELECT to_char('2016-12-31 13:30:15'::timestamp without time zone, 'yy/ww') ;
result:
16/53
Consider the following table
id | sell_count | created_at
Suppose I want to generate a report in MySQL by date of a given month. When an admin selects a month and year and hits get report button, I want to show them a monthly report from day 1 to day 31, group by date.
Suppose the table has no data for date 15th March. So it will not be visible in the result set as date: 2018-03-15 , sell_count: 0. Is it possible/better ways to include that specific date into the result set in MySQL? Currently I'm doing it in PHP.
I have a table of users with various dates like birthday, date of hire, and annual review date. The birthday may or may not have a year, the date of hire does have a year, and the review date does not have a year.
I want to be return a query across a date range that returns the rows with the dates calculated for the year of the date range for these recurring events.
For example:
A user with the following:
dob:1980-05-05
doh:2005-06-22
review:0000-10-01
Then if I query for a range of say, 2012-05-01 to 2013-12-01 I'd like it to return records like:
Event,Date
dob,2012-05-05
doh,2012-06-22
review,2012-10-01
dob,2013-05-05
doh,2013-06-22
review:2013-10-01
I realize that this probably will be done in separate UNION queries on each date field which is fine. This isn't exactly the same problem as finding dates x days in the future as I need the recurring date with the proper year in the given date range which may be over multiple years if the range is large enough.
I can only think of doing this programatically. First checking if the start and end range span over a year. Then split the dates into start date to end of year, start of year to end date etc. and run a query for each span.
My db is made of groups of entries (by user) with a row for each day of the week and also groups where there is only 1 row per week of the year. This week may start Sat, Sun or Mon.
The sql groups all these rows by user id and works fine for the entries where the user has a row for every day
The problem I have is selecting the users rows where there is only one entry per week
Basically if the rows date is 11th Feb 2012 then I need to be able to select that row if the start date criteria falls on that date or within that following week and all rows upto but not including the row where the date column is after the end date
I'm trying everything like dateadd in the sql but I just cannot get it to add these rows in.
Hope I've made myself clear.
Say I have two entries in the db
2013-02-02
2013-02-09
I have a start date of 2013-02-05 and an end date of 2012-02-13
I need to get those two row as:
the start date falls on or within the week of 2013-02-02
and I also need 2013-02-09 as the end date falls on or within the week of that date.
Hope that makes it a bit clearer.
Not sure exactly what your question is asking.
If your field is of mysql date or datetime type, and you wanted to find if there was an entry for a given week could you not use MySQL WEEK Function to find all entries for the given week, you may also need to include a restriction on YEAR too.
You could also include the following week, but you may encounter problems. The main problem being week 52+1 of 2012 wont give week 1 of 2013, but week 1 of 2012.