Using VB to get 1st of July in previous year - vb.net

I am trying to create a default date in SSRS using VB.
The date I am trying to create is the 1st of July in the previous year from the current year.
I am using something like this at the moment to get the current day in the previous year at 6am.
=CDate(Format(DateAdd("yyyy",-1,Now()), "yyyy-MM-dd") + " 06:00:00")

The expression to get 6pm of the 1st of July of the previous year is:
= Cdate(Cstr(Year(Today())-1) & "-07-01 06:00:00")
To get 6pm for the same date of the previous year
= Cdate(Cstr(Dateadd(DateInterval.year,-1,Today)) & " 06:00:00")

Related

Snowflake retrieving data of past month on a particular date of current month

I am new to snowflake and my manager wants me to retrieve the data of the past month when it is 5th of the current month. For example if today is 5th April, then ask snowflake to retrieve the data of the past month i.e. from 1st March 2021 to 31st March 2021 and similar for all the other months.
The reason why he wants to update the last month data on 5th of every next month because that is the day when we get the data.
I tried to use the DATEADD function but it is more complicated than just using this function.
Thanks in advance!
PS: The data for every month has same date. for example: the date is like - April 20th will be stored in the database as "2021-4-01" - and same for April 25th date will be stored as "2021-4-01" .
The day doesn't change in the database, just the month and year.
as to the prior month window that can be done via DATE_TRUNC and DATEADD
select
current_date as cd
,date_trunc('month', cd) as end_range
,dateadd('month', -1, end_range) as start_range
;
gives:
CD END_RANGE START_RANGE
2021-04-21 2021-04-01 2021-03-01
the other half of the question only do it on the 5th, if you have a task run daily etc. can be solved via
,day(current_date) = 5 as is_the_fifth
or if in an inline way
iff(day(current_date) = 5, <do true stuff>, <do false stuff>)

Access Report Year should be change after April every Year

The session is starting from every year from April to March.
The report needs to publish in twice in that year first report in October and another in March.
In both conditions year will be 2019-20.
After March session will change then the year will also automatically changed 2020-21.
How to resolve it?
Below expression will not work on this condition:
Format(Date(),"yyyy-") & Right(Year(Date())+1,2)
That needs an adjustment to the fiscal year, which can be done like this:
=Format(Year(DateAdd("m",-3,Date()))*100+(Year(DateAdd("m",-3,Date()))+1) Mod 100,"0000-00")
This offsets the date of the fiscal year to match a pseudo calendar year, thus allowing you to extract year and month as for any calendar year. The first year is returned in full and multiplied with 100: 201900 and added to the decade part of the second year: 201900 + 20 = 201920. This is finally formatted to have a dash: 2019-20.
So reports between April 2019 and Mar 2020 should show 2019-20.
Use conditional IIf:
IIf(Month(Date()) < 3, Year(Date()) - 1 & "-" & Format(Date(),"YY"), Year(Date()) & "-" & Right(Year(Date()) + 1, 2))
Problem with using Date() to calculate this is if report for March is run on April 1, calculation will be wrong. Might be best to reference textbox on form for beginning year.

Get past 6 months MONTH in ref to TODAY

Need help in displaying 6 month past month in refrence to todays date. E.g current month is June. below is the code, but is giving the as 1,I need to get January.
MsgBox ("Cheques would be checked for issue Month of " & (Month(Date)-5))
MsgBox ("your date is " & DateAdd("m", -6, Date()))

Print date in Month name day, year format

I'm looking to print the current date in Month name day, year format (example: October 3, 2014). I understand that I can get the current month in integer format with Month(Date) or Month(Now), but I want to know how I would output the current month in text format.
While waiting for nobody to answer this question I figured out that you can use the MonthName( number, [ abbreviate ] ) function to print the month name. As you can see from my example, the parameters of this function are number, which is a value from 1 to 12 representing the month, and abbreviate, which is an optional boolean. If this parameter is set to TRUE, it means that the month name will be abbreviated. If this parameter is set to FALSE or left out, the month name won't be abbreviated; now lets get back to answering the question.
Since Month(Date) returns the number of the month, you can set it as the first parameter of MonthName(); soMonthName(Month(Date))will return the name of the current month. You can then print the current date in the Month name day, year format with this code:MonthName(Month(Date)) & " " & Day(Date) & ", " & Year(Date)`.

QlikView Problems with Listbox

I want to have a list box that shows the following:
YYYY: WeekNumber - Date
The Date part is using a Broadcast Calendar (starts on Sundays, so week 1 of 2012 is actually Monday 12/26/2011).
This needs to be conditional:
If the year selected is the current year, only show through the latest "broadcastMonday" which in this case is Week 9 (2/20/2012). Then go back all the way through the prior year to week 1 of 2011, which is actually 12/27/2010.
If the year selected is less than the current year, only show all of that year plus all of the prior year.
The following expression for the List Box is working just fine for me with respect to displaying the right information, but when I click an item in the list it doesn't select it:
=If([Year]=year(ReloadTime()),if(left(BroadcastPeriod2,4)>=[Prior Year]
and BroadcastWeekStart2<ReloadTime(),(left(BroadcastPeriod2,4) & ' : ' &
BroadCastWeek2 & '-' & date(BroadcastWeekStart2)),),if(left(BroadcastPeriod2,4)>=
[Prior Year] and left(BroadcastPeriod2,4)<=([Year]),left(BroadcastPeriod2,4) & ' : '
& BroadCastWeek2 & '-' & date(BroadcastWeekStart2),))
I think the answer is to either do it in the load (concatenating the fields) or to use a table instead of the input box.
I would try to calculate the value for the listbox in the loadscript. I had trouble comparing StartMonth values in set analysis and could come around this by pre-calculating the values at load time.
Did something similar in Qlikview aggration with conditions