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
Related
I want to write in an Access report "final examination 2019-20" in that format.
This should be the four digit current year, followed by a two digit following year : yyyy-yy. Is there a way to Format the current Date() to solve this?
Try this, it should be what you need:
Format(Date(),"yyyy-") & Right(Year(Date())+1,2)
Note that when you don't use that expression in the VBE in a code window, but in a property field, commas must be replaced by semicolons.
This cannot be a Format but can be an Expression:
Year(myDate) & "-" & right(Year(myDate)+1,2)
Alternatively, you can use Format for both parts:
Format(Date(),"yyyy-") & Format(DateAdd("yyyy",1,Date()),"yy")
Or, for the fun, use Format once only:
=Format(Year(Date())*100+(Year(Date())+1) Mod 100,"0000-00")
Session is starting from every year April to March. Report need to
publish in twice in that year first report on October and another on
March. In Both condition Year will be 2019-20. After March Year will
change 2020-21 automatically.
That needs an adjustment to the fiscal year, which can be done like this:
=Format(Year(DateAdd("m",9,Date()))*100+(Year(DateAdd("m",9,Date()))+1) Mod 100,"0000-00")
I have been trying to make my user form work by getting codes everywhere. I don't have any experience in VBA so the code that I have are patches from different sources.
I have a datepicker control in my user form and i'd like to get the corresponding week number, month number and year based on the date that is chosen from the datepicker control box and populate the corresponding textboxes for each
datepicker and textbox dependencies.
To get the week number use the below. The third and fourth arguments allow you to dictate the first day/first week of the year.
TextBoxWeek.Value = DatePart("ww", TextBoxDatePicker.Value, vbMonday, vbFirstJan1 )
Month:
TextBoxMonth.Value = format(TextBoxDatePicker.value,"mm")
Year: (you can also use "yy" to get the shorthand date eg. '17' rather than '2017')
TextBoxYear.Value = format(TextBoxDatePicker.value, "yyyy")
I am having a really difficult time with this excel table and was trying to use VBA as well as Excel functions to get the date formatted into Year, Month, Week but I keep running into issues.
I have the below input:
The reason Column1 looks so odd is because I was TRYING to use =MONTH([Date]) but it looks all weird and doesn't sort into the month or week it is supposed to.
Below is the expected outcome if everything were to work.
So using the Date column I want to generate 3 columns: Year, Month, Week
Any idea if I am doing something wrong in excel or if there is an easy way to do this in VBA?
with the date in A2 , in E2 enter:
=A2 and format as "yyyy"
In F2 enter:
=A2 and format as "mm-mmmm"
In G2 enter:
="Week " & ROUNDUP(DAY(A2)/7,0)
Not sure where the issue is but the following formulae will give you year, month, and day. Where a1 contains a date
=year(a1)
=month(a1)
=day(a1)
Of course if you want the month to show the month in words rather than a number you can format the cell as custom and then mmm
You are using the right formula the only thing amiss is your column formatting as it is correctly pointed out in the comments. Follow these steps to get the desired formatting
Select the column and right click Click 'Format Cell'
In the'Number' tab select 'Custom' in the category list
Enter 'mm - mmmm' as the type.
You should get '12 - December'
Formula for year: =YEAR([#Date])
Formula for month: =MONTH([#Date]) & "-" & TEXT([#Date],"mmmm")
Formula for week: ="Week " & WEEKNUM([#Date],2)-WEEKNUM(EOMONTH([#Date],-1)+1,2)+1
and use appropriate format for each column.
I have a yearly chart that it broken down into the 12 months Jan - Dec. The report contains various parameters including a yearly dropdown that changes the chart and report.
This all works fine within the first report.
The problem is that I have set up an action on the chart to go to a second report with a monthly breakdown, so my question is how can I pass the monthly value from the first report to the second?
The monthly report has an additional date from and date to parameter, so for the month of January it would need the values: Date From: 01/01/2010 and Date To: 31/01/2010 for example.
Thanks in advance.
Since you have the year and month integer values, you can construct the start and end dates to pass to your other report using expressions.
The start of the month will be:
=DateSerial(Fields!Year.Value, Fields!Month.Value, 1)
Where Year and Month are the integer values from the Chart/Dataset.
The end date is a bit more complicated; since the day part can be 30/31, etc, but we can just add one month to the above expression to get the first of the next month, then go back a day:
=DateAdd(DateInterval.Day
, -1
, DateAdd(DateInterval.Month, 1, DateSerial(Fields!Year.Value, Fields!Month.Value, 1)))
This way your drillthrough report can get its date based parameters and you don't need any changes to your dataset/parent report.
I just don't know how to go about this.
I designed a program that uses MS Access as its database. I have a field for month and year (the field data type is text) where user can register details. The program will register the month and year the user have chosen e.g month= September, year=2011.
My problem now is how to chose a range of data to view by the user using the month and year as a criteria e.g the User may want to view data range from (September 2011 to July 2013).
I couldn't figure out even how to try. Help will be highly appreciated.
Perhaps you could change your application logic to store the month and year as their respective numbers rather than text and change the field data types to numeric.
You could then construct a DateTime object from them, for example September would be 9 and you could use code like the following:
var startDate = new DateTime(year, month, 1); // get year and month as integers from database, uses the first as the date
var endDate = new DateTime(year, month, 10); // change the date but keeps the month and year the same
var endDate2 = startDate.AddMonths(1); // adds 1 month to the date
Alternatively, you could try using a calendar control to allow the user to select two dates instead of building it from a number of fields. Depending on what you are using this could be achieved a number of ways, for example in ASP.Net or WPF you could use two calendar controls and just use their SelectedDate properties as your range.
A range is from a startpoint until an end point. For the startpoint you can add automatically the first of Month. For the endpoint is it more complicated because there is no fix endpoint. What you can do is following:
Write an array that contains for each month the days (e.g. 30 or 31). Except for Febrauary there is a fix pattern.
for Febrauary use the selected year to check is the year a leap year or not. If not add 28, else add 29.
After that create the date string for your SQL:
Startdate 1.9.2011. Do for the entdate the same.
After that, I think you can use the keyword between in your SQL query.
You can assume that everything is entered on the first day of each month. I would pull the information using a query to the database.
select * from [tablename] where DateSerial([colYear], [colMonth], 1) between DateSerial([fromYear], [fromMonth], 1) and DateSerial([toYear], [toMonth], 1)
In this question are some ways to do this:
First. Filter the dates in a range assuming that you use a date like '07-12-2012'
i.e. September 2011 to July 2013
Where DateColumn > '09-01-2011' and DateColumn < '07-31-2013'
OR
Specify a Date and a Year
Where month(DateColumn)='1' and year(DateColumn)='2016'
Note:
There are many ways to do this.
You can Manipulate your statement depending on your desired output.