I'd like to create a CALM query to get days and months of any year. Example:
In a list with the results below, I'd like to get all dates that have day equals 10 and month equals 07:
07/10/1984
01/02/2001
05/12/1991
07/10/2007
So, the result would be:
07/10/1984
07/10/2007
I don't think you will be able to do it directly in CAML for any year so you would end up listing out that day and month range for every year - bit of a monster.
Are you able to add extra calculated columns to your list? If so then you can add
DayAndMonth = Day([YourDate]) & "-" & Month([YourDate])
Then its a simple case of filtering using CAML or normal view filter (assuming US date format)
DayAndMonth = "7-10"
Related
I have the following dataset in tibco spotfire:
Original data
I want to bring the amount of item in the beginning of each month for each row and get the following result:
Image
Any suggestions?
The dataset looks like this: I have got maximum amount for previous month, but I want to get the amount of the last day of the previous month.
enter image description here
I could do it via an intermediate column (as Spotfire's OVER does not accept expressions).
First calculate the year and month like this:
(assuming the format of your date is known and stable)
[YearMonth] is :
Integer(Concatenate(Substring(String([Date]),7,4),Substring(String([Date]),4,2)))
then your [Previous Month] is:
Max([Amount]) over (Intersect(Previous([YearMonth]),[BRANCH],[CLASS]))
and your [Diff] is:
[Amount] - [Previous Month]
Revised after comment 19 August:
change the Max to ValueForMax and insert the day of the month, so that the formula calculates the value
corresponding to the last recorded day for that month:
ValueForMax(DayOfMonth([Date]),[Amount]) over (Intersect(Previous([YearMonth]),[BRANCH],[CLASS]))
Revised after comments 6 October:
if Substring(..) is not available, here is an alternative solution:
Create a new column (to make the expressions understandable): [StringMonth] as:
If(LongInteger(Month([Date]))>10,String(LongInteger(Month([Date]))), Concatenate('0',String(LongInteger(Month([Date])))))
Then calculate your [YearMonth] as:
Integer(Concatenate(Year([Date]),[StringMonth]))
I have a table that has a series of Columns with data I need to split out. Example below
STATUS#10/16 12:00:00 (CODE)
I've been able to split it easy enough and when I originally tried to set the date on an older dataset it identified it as a date e.g. 16th Oct 2021 However I started to get errors on this date column and trying with different datasets (10/12, 10/13, 10/14) it is not finding the date. I tried the following query code but I'm receiving errors
[STATUS DATE] is split to 10/14, 10/15 etc
#date( Date.Year(DateTime.LocalNow), Date.Month(Text.End([STATUS DATE]), 2), Date.Day(Text.Start([STATUS DATE]),2))
However I'm getting a function error so I tried
Date.From(Date.Day(Text.Start([STATUS DATE]),2) & Date.Month(Text.End([STATUS DATE]),2) & Date.Year(DateTime.LocalNow)
I have also tried to do this from an example column however the query created is looking at the cell value e.g. if 10/14 then 14/10/2021 else if 13/10 then 14/10/2021. This method i feel is prone for error once I include a larger dataset.
Is there anyway I can determine the date value based on mm/dd format? But with year end in mind, make the YYYY be determined by current year unless we move into Jan and then I don't want the Oct, Nov, Dec value showing as 2022.
You don't really show what your original data looks like.
But if it is like:
Source
Then you can use this code in the Add Custom Column dialog:
let
split=Text.SplitAny([STATUS DATE],"#/ "),
mnth = Number.From(split{1}),
dy = Number.From(split{2})
in
#date(Date.Year(DateTime.LocalNow()),mnth,dy)
The Text.SplitAny function lets you input a list of delimiters and the text will split on all of them. So it is relatively simple to extract the month and day values
to create:
Split [STATUS DATE] one more time into [Month] and [Day] column, using the "/" as a separator. Then you don't have to bother with 1 or 2 digit numbers and you can simply use this formula:
#date(Date.Year(DateTime.LocalNow()), [Month], [Day])
DateTime.LocalNow() is a function, so you need to add the brackets.
[Month] and [Day] are numbers already, so you don't need the Date.Month() or Date.Day() functions.
I'm having trouble writing code in VBA that would allow me to input any given date then have an output of the current work week. I need a restriction of if the date is Sunday through Tuesday, it will keep that current work week and year but if the date is Wednesday through Saturday, then the next work week and year will show. For example, I'm looking to input (5/28/19) and have an output of 201922 or an input of (5/29/19) with an output of 201923 even though its technically the same work week.
Before getting too in depth, I do have a working function that provides the year and work week, but I'm trying to adapt the function or add a separate function that will change in to the next work week according to the given date.
I'm new to VBA but have tried to do a little research over the last few days. I was thinking that I could somehow have one input of the date then have two outputs where one would be the year and work week then the other would be the number associated with that date (1 for Sunday, 2 for Monday, and so on). I tried to create an if then statement that says if the number associated with that date is 1, 2, or 3 then the workweek would stay the same. If it was any other number then 1 would be added to that work week so it would move to the next one. I'm having trouble with trying to make two outputs and have them connected, if that makes any sense.
This is the code that I tried to create, but continuously failed at making. The function that gives the correct work week (without the adaptation of the work week based on the date weekday) is WWV1
Function WWV2(WeekdayName As Integer)
Dim WWV1 As Integer
If WeekdayName(Date) = 1 Or 2 Or 3 Then WWV1 = WWV1
Else: WWV1 = WWV1 + 1
End Function
This provides the cell with #NUM! when I use the function in that cell, which I assume is because I need to somehow connect the two functions.
how about this:
=YEAR(A1) & TEXT(WEEKNUM(A1,13),"00")
WeekNum returns the weeknumber with 13 saying it starts on Wednesday:
VBA
wkcd = Year(Range("A1")) & Format(Application.WeekNum(Range("A1")),"00")
hi guys i have the expression below which i am trying to use to concatenate some int param values and one int value.
In the end i want a date for the last day of the month based on what the user selected.
Spent all day on this, couldn't find anything in stack.
=Parameters!Year.Value & 10 & IIF(LEN(Parameters!Period.Value) <= 1,0 &
Parameters!Period.Value,Parameters!Period.Value)
Supposing that "Period" is the month, you are most likely looking for something like this:
=DateSerial(Parameters!Year.Value, Parameters!Period.Value, 1).AddMonths(1).AddDays(-1)
I have a list of cost figures with start dates and end dates which I need to split between months, I have searched for the solution to this problem but cannot seem to find one that will work with partial months i.e.( startdate:01/01/2015 enddate: 15/04/2015 cost:10000) which would leave figures like Jan:2857, Feb:2857, Mar:2857, Apr:1429.
I have been trying to modify this example: http://www.excel-university.com/excel-formula-to-allocate-an-amount-into-monthly-columns/ but having no luck getting the partial months working.
Any suggestions or help would be most welcome. Thanks in Advance
if you calculate it on daily basis, would it be ok? the result would be:
01.01.2015 01.02.2015 01.03.2015 15.04.2015
2.857,14 2.857,14 2.857,14 1.428,57
your daily amount is:
=10.000/(DAYS360(startdate;enddate;TRUE)+1)
(be carefull of true and false argument)
under the dates or instead of 2.857,14 etc. insert the formula:
=IF(DAY("your date")>1;DAY("your date");30) * daily amount
This formula assumes that you want to have 30 days in each month:
=IF(DAY(01.01.2015)>1;DAY(01.01.2015);30)
result = 30
=IF(DAY(15.04.2015)>1;DAY(15.04.2015);30)
result = 15
so if months begins with a date different from the 1st it will give you the number of days.
if you want to match months with your startdate and enddate (if i understood your comment correctly), you could do:
=IF(OR(
AND(MONTH(startdate)=MONTH(your date);YEAR(startdate)=YEAR(your date));
AND(MONTH(enddate)=MONTH(your date);YEAR(enddate)=YEAR(your date))
);"match";"no match")
by this you make sure that month and year correspond.
If you want to get the number of days in a month automatically, you could use:
=DAY(DATE(YEAR("your date");MONTH("your date")+1;1)-1)
but this does not assume anymore 30 days, you can change it with if statement
I hope this helps,
Best - AB