How to make and saved search to verify todays employee has exactly 1 year on company.
Example:
employee1 hiredate = 10/02/2015
employee2 hiredate = 11/02/2015
employee3 hiredate = 10/02/2012
employee4 hiredate = 10/02/2008
employee5 hiredate = 13/04/2008
Get saved search with all employee are 1 or more years old.
The result will be if today are 10/02/2016:
employee1 = 1 year on company.
employee3 = 4 year on company.
employee4 = 8 years on company.
Thats possible?
My wrong formula are:
MOD((ROUND({today},'DAY')-ROUND({hiredate},'DAY'))/365, 1) is 0
Thanks!
You should not need a formula at all for this. You can just set up a filter on your saved search where the field is "Hire Date", the operator is "on or before", and the value is "same day last fiscal year". If you only want exactly one year ago, you can use "on" instead of "on or before".
If you want Employees that are more than 1 year but less than 2 years, then just add a second filter of "Hire Date - on or after - same day fiscal year before last".
I was able to achieve the same using the below formula(numeric) filter:
MOD(MONTHS_BETWEEN({today}, {hiredate}),12) is equalto 0
this will give you the employees having anniversary.
To get the number of years add the formula(numeric) search column with formula:
FLOOR(MONTHS_BETWEEN({today}, {hiredate})/12)
Related
I'm new to python and new to pandas. Of course, if my project used exact dates, I could easily do this, but unfortunately, the date type is a little different, and as you can see, the sign 08 is after the year 1401, which means it is the eighth month of the year 1401.
I currently know that these 3 customers have bought from me this month. But I want to know if these 3 customers bought from me in the previous month or two months ago? If they do, I will give them a discount.
Of course, I should also say that the number 08 is not always fixed, but it could be 09 in the next month. I just want to know if they bought from me 1 month ago or not?
According to the picture, now only Sara should get a discount
You could convert the purchase date to an integer and calculate the number of months from there.
For instance, you have the purchase month 1901/07 and you want to know in 1901/08 how many months the last purchase took place. So you convert both values to integers and subtract them (190108 - 190107 = 1).
import pandas as pd
df = pd.DataFrame({'customer': ['david', 'sara'], 'date': ['1901/03', '1901/07']})
# Manually setting the reference month (190108 for Year 1901 and Month 08)
df['months'] = 190108 - df['date'].replace('/', '', regex=True).astype(int)
# Check if eligible for discount
df['discount'] = df['months'].isin([1, 2])
customer
date
months
discount
0
david
1901/03
5
False
1
sara
1901/07
1
True
To compare with today's month you could to the following:
df['months'] = int(pd.Timestamp.now().strftime('%Y%m'))\
- df['date'].replace('/', '', regex=True).astype(int)
I'm trying to find the customers whose birthday is in next month and the way the birthdays of customers will be entered at the stores is, they just ask for day and month and put in the current year for year.
So, when I', trying to do the search as next month it seem like I can only search with in a range that include year, which don't work in this case.
I've tried the below with search field set to is february but it don't automate the search as I have to change the month every month
TO_CHAR({custentity_spos_date1},'MONTH, YYYY')
Does some one have any idea how to include only month in search so that I can search for customers who's birthday is in a particular month?
case
when to_char({today}, 'MM') = '12' then
case
when to_char({custentity_spos_date1}, 'MM') = '01' then 1
else 0
end
when to_number(to_char({custentity_spos_date1}, 'MM')) = to_number(to_char({today}, 'MM')) + 1 then 1
else 0
end
equal to 1
The filter basically says if the month of the current date is 12, then match any record where the month of the date field is 1, otherwise match any record where the month of the date field is equal to the month of the current date + 1.
There may be an easier way, but this worked for me.
You can use the SQL formatting and ADD_MONTHS functions to compare only the month component of the date:
CASE WHEN TO_CHAR({custentity_spos_date1}, 'MM') = TO_CHAR(ADD_MONTHS(sysdate, 1),'MM') THEN 1 ELSE 0 END
Equal to 1.
I have a pivot table which currently looks like this:
No of Sales
Team 1
2017-03-10T07:10:20.289Z 1
2017-03-10T07:10:22.289Z 4
2017-03-14T07:08:20.289Z 10
Team 2
2017-03-11T07:14:20.289Z 11
I want to group by the date in the timestamp and only show the date and the total for that day so it looks like this instead:
No of Sales
Team 1
2017-03-10 5
2017-03-14 10
Team 2
2017-03-11 11
How can I do this?
you can do the rest of the code, but the important part is:
strTemp= cells(row, col).value 'this contains the date 2017-03-10T07:10:20.289Z
strDate = split(strTemp, "T")(0)
That's it.
Using the Start Date and End Date of PTO - Personal Time Off Days Used only count days used up to end of prior month, excluding weekends and U.S Holidays in that certain month. Example of a Holiday is Sept 7th 2015 in the United States.
My goals are:
Create a Data Item Month End Personal Time Off Days used.
Of course it should be getting the number of PTO Days USED from the prior month only.
Exclude weekends in that certain month. So if the Resource takes a Leave on Friday and Monday, Saturday and Sunday should not be excluded in the computation.
How to exclude U.S Holidays, if this is possible that's great but if it's not possible then I'm okay with numbers 1, 2 and 3.
I have created a Data Item column that captures the PTO days used. But this is good for Year to date.
Case when [PTO Info].[PTO Audit].[PTOAuditTypeId] = 31571
and [PTO Info].[PTO Audit].[TimeOffTypeId] = 31566
then [PTO Info].[PTO Audit].[PTODays]
when [PTO Info].[PTO Audit].[PTOAuditTypeId]=31572
and [PTO Info].[PTO Audit].[TimeOffTypeId] = 31566
and [PTO Info].[PTO Audit].[PTODays] < 0
then abs([PTO Info].[PTO Audit].[PTODays] )
else 0 end
I'm not sure if the query below can help.
A calendar table is really going to help you out here. Assuming it has one record per calendar date, you can use this table to note weekends, holidays, fiscal periods vs Calendar periods, beginning of month/end of month dates. A number of things that can help simplify your date based queries.
See this question here for an example on creating a calendar table.
The main point is to create a data set with 1 record per date, with information about each date including Month, Day of Week, Holiday status, etc.
Without a calendar table, you can use database functions to generate your set of dates on the fly.
Getting the Month number for a date can be done with
extract([Month], <date field goes here> )
Getting a list of values from nothing will be required to generate your list of dates (if you don't have a calendar table with 1 record per date to use) will vary depending on your source database. In oracle I use a 'select from all_objects' type query to achieve this.
An example from Ask Tom:
select to_date(:start_date,'dd-mon-yyyy') + rownum -1
from all_objects
where rownum <=
to_date(:end_date,'dd-mon-yyyy')-to_date(:start_date,'dd-mon-yyyy')+1
For Sql Server refer to this stackoverflow question here.
Once you have a data set with your calendar type information, you can join it to your query above:
join mycalendar cal on cal.date >= c.PTOStartDate
and cal.date <= c.PTOEndDate
Also note, _add_days is a Cognos function. When building your source queries, try and use Native functions, like in oracle you can 'c.PTOStartDate + a.PTODays'. Mixing Cognos functions with native functions will sometime force parts of your queries to be processed locally on the Cognos server. Generally speaking, the more work that happens on the database, the faster your reports will run.
Once you have joined to the calendar data, you are going to have your records multiplied out so that you have 1 record per date. (You would not want to be doing any summary math on PTODays here, as it will be inflated.)
Now you can add clauses to track your rules.
where cal.Day_Of_Week between 2 and 6
and cal.Is_Holiday = 'N'
Now if you are pulling a specific month, you can add that to the criteria:
and cal.CalendarPeriod = '201508'
Or if you are covering a longer period, but wanting to report a summary per month, you can group by month.
Final query could look something like this:
select c.UserID, cal.CalendarPeriod, count(*) PTO_Days
from dbo.PTOCalendar c
join myCalendar cal on on cal.date >= c.PTOStartDate
and cal.date <= c.PTOEndDate
where cal.day_of_week between 2 and 6
and cal.Is_Holiday = 'N'
group by c.UserID, cal.CalendarPeriod
So if employee with UserID 1234 Took a 7 day vacation from thursday June 25th to Friday July 3th, that covered 9 days, the result you get here will be:
1234 201506 4
1234 201507 3
You can join these results to your final query above to track days off per month.
I am trying to calculate if someone was employed in the last 12 months based on 2 date fields. Joined date & Date left. If they were an employee in the last 12 months and have not left return 'Yes' if they either joined in the last 12 months or left in the last 12 months return 'No'.I also want it to only show full time employees based on a column that contains ('Contract' / 'FT').
The image linked table shows the inputs. I want a formula to calculate the 'Employeed in last 12 months'.
Thank you.
!https://imgur.com/a/BbavKep
You can add a new column in your table, with expression like this:
= Table.AddColumn(#"Changed Type", "Employeed in Last 12 Months",
each if [#"Contract/FT"] <> "FT" then "No"
else if [Date Left] <> null then "No"
else if [Date Joined] > Date.AddYears(Date.From(DateTime.LocalNow()), -1) then "No"
else "Yes")
DateTime.LocalNow() returns current date and time. This value is recalculated when you reload the data (note, it will not be recalculated automatically in time - you must reload the data).
Date.From will truncate the time part.
Date.AddYears will add -1 years, i.e. will calculate the date 1 year ago.
IF('Table'[Contract/ FT]="FT";
IF(DATEDIFF('Table'[Date Joined].[Date];TODAY();MONTH)>12;
IF(ISBLANK('Table'[Date Left]);
"YES";
"NO");
"NO");
"NO")
Add new column and add above expression, it will give you desired results