Getting Month Names From Current Month to April - sql-server

How can I get The months names from Current month to April only using SQL
Ex:-if the current month is July then I want the month names from July to April.
Current month should be the running month.
Any function or something like that....(I need to get the data from Db for those months)

This should work:
WITH Dates AS
(
SELECT GETDATE() D
UNION ALL
SELECT DATEADD(MONTH,1,D) FROM Dates WHERE DATEPART(MONTH,D)!=4
)
SELECT DATENAME(MONTH,D) [Month Name] FROM Dates
Result
Month Name
------------------------------
September
October
November
December
January
February
March
April

Related

MonthName-Year as SSRS parameter

I have dimTime table below:
TheYear Fiscalyear TheMonthName TheMonth
2022 2022 - 2023 November 11
2022 2022 - 2023 October 10
2022 2022 - 2023 September 9
2023 2022 - 2023 February 2
2023 2022 - 2023 January 1
How to implement the MonthName and Year as SSRS parameter and have this in the main dataset? Like below:
Select Month-Year: January-2023
Dataset: Select
from Table
where date = selected MonthYear from the parameter
This will also goes to same report but the selection is Fiscal year:
*Select Fiscal Year: 2022-2023
Dataset: Select
from Table
where date = selected FiscalYear from the parameter
Im trying to convert it to date but dont know where to start.

Produce data extracts using day field for the Friday before the weekend

Using TSQL on SQL Server...
I need to produce extracts that use a pay day column in a database that only holds the day number, for example 26 to produce extracts for the 26th day of the month with a twist if that pay day falls on a weekend then the data for that extract should be extracted the Friday before the weekend.
Has anybody attempted this and able to offer some ways of achieving this through TSQL?
Thanks
You have said in today's comment above that you are assuming the current month.
First turn your payday day number into a proper date:
select dateadd(month,((year(getdate())-1900)*12)+month(getdate())-1,payday-1)
as paydate
and then use a case statement against it:
case datename(weekday,paydate)
when 'Saturday' then dateadd(day,-1,paydate)
when 'Sunday' then dateadd(day,-2,paydate)
else paydate
end as paydateadjust
(Obviously these will need rewriting into a proper SQL statement. Date formula borrowed from Michael Valentine Jones' super useful SQL Server date function.)
I'm assuming you have the month and year available too, in which case you can construct a real date, and get the day of week from it as a 1-based number starting at Sunday. So, 6 equals Friday. This will produce 5 for today, as Thursday = 5
SELECT DATEPART(dw, DATEFROMPARTS(2018, 07, 26)) AS [DayOfWeek]
EDIT:
I'll make another assumption, this time that this is somehow possible, like it's always run for the current month. This is a bit dodgy as it all falls apart if it's run too early or too late, but at least it's achievable.
SELECT DATEPART(dw, DATEFROMPARTS(
DATEPART(YEAR, GETDATE()),
DATEPART(MONTH, GETDATE()),
26)) AS [DayOfWeekThisMonth]
EDIT 2:
OK, with the understanding we are working on this month, we can do this:
DECLARE #PayDayNumber INT = 29; -- Replace this with a SELECT to get your value
SELECT CASE(DATEPART(dw, DATEFROMPARTS(DATEPART(YEAR, GETDATE()), DATEPART(MONTH, GETDATE()), #PayDayNumber)))
WHEN 1 THEN #PayDayNumber - 2
WHEN 7 THEN #PayDayNumber - 1
ELSE #PayDayNumber
END AS [WeekendSafePayDay]
For this month (August 2018) the 29th will return 29th. You can change DATEPART(MONTH, GETDATE()) for 9 to test September, which will return 28 because 29th September is a Saturday, or change it to 7 to test July, which will return 27 because 29th July is a Sunday.

Convert the whole date to string format

I am working in sql query like this:
Display the STARTING_DATE in the following format – β€˜The fifth day of the month of
October, 2004’.
For example,
10-5-2004 should be displayed as'The fifth day of the month of October, 2004’
Use MySQL's DATE_FORMAT to format date.
SELECT DATE_FORMAT('2017-09-21', 'The %D day of the month of %M, %Y');
Output
The 21st day of the month of September, 2017

How can i get week no of year in sql server for year and month name

i want to get week no of year from sql server . i have two input 1.Year name and 2 .month name .
like
Year ---- '2016'
Month --- 'April'
Week no --- 1,2,3,4
Year --- '2016'
Month ---'May'
Week no ----5,6,7,8
when user select year --- 2016 and month name --- April then i want list of week no. like 1,2,3,4 of April month as financial year wise.
If you have a date as input(mm-dd-yyyy), this should help:
DECLARE #Dt datetime
SELECT #Dt='02-10-2016'
SELECT DATEPART( wk, #Dt)

Week end Date in netezza

I am looking for week start and end date in Netezza but my week starts from Mon and ends on Sun
Date Week Start Date Week End Date
11/30/2015 11/30/2015 Mon 12/06/2015 Sun
Day of Week functions begin on Sunday in Netezza
Template Patterns
Extract Function
You'll need to use modulo in order to deal with Sunday.
select
current_date
,current_date - mod(extract(dow from current_date) - 2),7) week_start
,week_start + 6 week_end

Resources