grouping query results by months - coldfusion

I have a coldfusion query result, which contains only dates
like
2015-07-14 00:00:00.0
2015-07-22 00:00:00.0
2015-07-24 00:00:00.0
2015-07-27 00:00:00.0
2015-08-04 00:00:00.0
2015-08-05 00:00:00.0
2015-08-15 00:00:00.0
2015-09-01 00:00:00.0
2015-09-02 00:00:00.0
2015-09-21 00:00:00.0
2015-10-14 00:00:00.0
2015-12-10 00:00:00.0
2016-01-13 00:00:00.0
I want to display query results grouping them on months basis
e.g
Month's name as first column and then dates of that month per row.
I have no idea how to group the query in this sitution.

Update your query to have a year and month column. You don't specify your DMBS but for MSSQL you would use the year(), month(), and day() functions. Make sure your query is ordered by year, month and day otherwise the grouping will not working properly. ColdFusion also has a built in function called monthAsString() to cast an integer to the month name.
SELECT year(datecolumn) AS Year, month(datecolumn) AS month, day(datecolumn) AS day, other, columns
FROM mytable
WHERE x = y
ORDER BY year, month, day
Output as
<cfoutput query="myquery" group="year">
<cfoupt group="month">
#monthAsString(month)#
<cfoutput group="day">
#day# #other# #columns#
</cfoutput>
</cfoutput>
</cfoutput>

Related

In Power bi Date slicer can we only show the end of month dates instead of showing all the dates?

I have a report where I have sales data for end of every month. When I see the data in drop down ,I can see the end of month date , but when I have used slicer it shows the entire date range and not only the last day of the month. Is there any way in slicer through which I can just limit the date, so that only last day of month will be shown in slicer ?
If you have a dates table with a date field (named Date, in this case), you could add a column with this code: Table.AddColumn(PreviousStep, "EndOfMonth", each Date.EndOfMonth([Date]), type date)

Extracting day in a new field from a date in Pentaho

I have a field with a date in yyyy-MM-dd format, I want to extract the day only, for example, if the date is 2014-01-25, I want to have "25" in a new field. I used step "Calculator" is calculation "day of month of date A" but I get 1970-01-01 01:00:00 for all records.
Could someone tell me what might be the reason?
Before you actually have the Calculator step, have a Select Values step and make sure the date field is Date by explicitly giving the Date data type and specify the format it is currently in.

How to extract Month and Year from column in PowerBI powerquery

I have a column (monthyear) in the image below. I want to extract the Month and year from the column to put it in the new column. Note: In my dataset this information goes for every day of the year
So the new column would look like:
01/2020
01/2020
01/2020
etc.
In Power Query, use some of the date functions.
To get the year it will be
Date.Year([monthyear])
For the month, it will depend on how you want to format it. Using the month of June as an example:
To get 'Jun'
Date.ToText([monthyear],"MMM")
To get the month number in the format 06
Number.ToText(Date.Month([monthyear]), "00")
Just to get the number 6 it will be:
Date.Month([monthyear])
In DAX use the date functions
For year the calculated column will be:
YEAR([monthyear])
For the month:
MONTH([monthyear])
I would always do a much data transformation in Power Query when you can before it gets to the data model.

Get Current Month and Year from Date Powerbi

Looking to get the current month and year from date column.
Below one not working:
FORMAT(Date(MONTH(Dim.DateTable.Date.Today())),"MMMM")
If you want an extra column with only the month, you can use:
FORMAT(yourTable[yourDateColumn],"MMMM")
If you want a date to show consistant over your report as MMMM yyyy, select the column, click tab modeling and select the format of the column there.

In sas application Set date parameter and put it in the contacted column to retrieve data in a certain period

The date in the table is not one set,
Days in the days column and months in the month column and years in the year column
I have concatenated the columns and then put these concatenation in where clause and put the parameter I have made but I got no result
I assume you are querying a date dimension table, and you want to extract the record that matches a certain date.
Solution:
I created a dates table to match with,
data dates;
input key day month year ;
datalines;
1 19 2 2018
2 20 2 2018
3 21 2 2018
4 22 2 2018
;;;
run;
Output:
In the where clause I parse the date '20feb2018'd using day, month & year functions: in SAS you have to quote the dates in [''d]
proc sql;
select * from dates
/*if you want to match todays' date: replace '20feb2018'd with today()*/
where day('20feb2018'd)=day and month('20feb2018'd)=month and year('20feb2018'd)=year;
quit;
Output:
if you compare date from day month and year, then use mdy function in where clause as shown below. it is not totally clear what you are looking for.
proc sql;
select * from dates
where mdy(month,day, year) between '19feb2018'd and '21feb2018'd ;