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.
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 2 columns (year and month). A sample data of year column A is 2015 at cell A2. A sample data of month column B is Jun at cell B2. I would like to convert these data to date format in column C to '2015-06-00` at cell C2. Is there a formula or Excel VBA to do this?
First off, 2015-06-00 is actually 31-May-2015. If you supply zero as the day-of-the-month, you get the last day of the previous month. Typically you would set it for the first day of the month. Use the DATE function for this with 1 as the day_num parameter or the DATEVALUE function if you are stringing together text-that-looks-like-a-date.
=datevalue(B2 & " 1, " & A2)
With a three letter month in B2, you will have to translate that to a numerical month if you opt for the DATE function.
=DATE(A2, LOOKUP(B2, {"Apr","Aug","Dec","Feb","Jan","Jul","Jun","Mar","May","Nov","Oct","Sep"}, {4,8,12,2,1,7,6,3,5,11,10,9}), 1)
in cell C "=FECHA(A2;B2;1)" (spanish excell)
I have two columns in excel like column send out date & column received date. I want to compare each "Send Out Date & Received Date", if the difference is longer than 3 working day exclude Sunday then turn the "received date cells" will RED color.
[Send Out Date] [Received Date]
26-May 28-May
26-May **29-May**
In excel 2010:
select the range you want to format (e.g. B2:B3 in your example)
in home tab select conditional formatting - new rule - use a formula to determine which cells to format.
type this: =NETWORKDAYS.INTL(A2,B2,11)>3
click format and set the formatting you need.
I am trying to write an Excel VBA function that outputs the final day in a month in the format yyyy-mm-dd when given only the month number as an integer.
So for January, a 1 would be input and the output would be 2014-01-31.
I know how to reformat the date using Format(date(), "yyyy-mm-dd") and think I can calculate the last day using DateSerial but am not sure how to input an integer month number into the DateSerial function.
What is the best way to go about this?
Try:
Function: =TEXT(DATE(2014, A1 + 1, 1)-1,"yyyy-mm-dd")
VBA: DateSerial(Year, Month + 1, 1) - 1
This function finds the first day of the next month and then subtracts one day.
Paste into any cell except A1 and input your month in A1 to test.
As a formula, with your formatting, assuming the year is 2014 and your month number is in A1:
=EOMONTH(41639,A1)
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