I want to calculate age with birth day and current day. result should be "years-month-day".How can i do ? Please help.
i'm try this but not be great
DateDiff(“yyyy”,birthday,currentday)
if current date is 20/05/2015 and birth date is 1/06/1991, result = 24 but it should be 23 years 5 month 19 days
If (Not(isNull({#birthdate}))) Then
ToText(int(DateDiff('d',{#birthdate},CurrentDate())/365.25),0)+' Years '+
ToText(int(remainder(DateDiff('d',{#birthdate},CurrentDate()),365.25)/30),0)+' Months '+
If day(CurrentDate()) < Day({#birthdate}) Then
ToText(day(dateserial(year({#birthdate}), Month({#birthdate})+1,1-1)) - Day({#birthdate}) + Day(CurrentDate()),0) + ' days'
Else
ToText(day(CurrentDate()) - day({#birthdate}),0) + ' days'
No perfect but works nicely.. here is an article to read that might help as well for
calculating birthdays
Related
Good afternoon!
I am trying to write a sumifs function that will add up the "Total Gross Income" with the corresponding year and week number
Example
Week Number = 21 && Year = 2021 --> $602.85 ($68.75 + $117.60 + $285.00 + $131.50)
Week Number = 21 && Year = 2022 --> $47.42 ($7.75 + $6.25 + $17.06 + $16.30)
I tried to run this function:
=arrayformula(if(C2="","",sumifs($D$2:$D$9,$C$2:$C$9,C2:C)))
But, it will only return the total sum for the year 2021
Here is a link to a copy of the sheet: https://docs.google.com/spreadsheets/d/1eZbSQD6WxpFyaNw58htAT-d12kHZgIRIFofbdHtN9Ic/edit?usp=sharing
use:
=INDEX(IFNA(VLOOKUP(B2:B&C2:C, QUERY({B2:B&C2:C, D2:D},
"select Col1,sum(Col2) group by Col1 label sum(Col2)''"), 2, )))
Good day,
I would like to create parameters with the following conditions:
Start Date Range between 03/01/2019-03/31/2019 (done)
End day range 03/01/2019-03/31/2019
Default end day is set to the day of today but in March (so if I open the wbook tomorrow it will be 03/22/2019
It's a bit complexe and your help is much appreciated.
1- Create calc field that takes day of today and month/year
DATEPARSE("dd, MM, yyyy", str(Today()) + ", " + str(03) + str(2019))
2- In End date parameter > when opening workbook > select calculated date
I'm trying to work with Year and Week in combination and would like to include leap years when they occur.
In my code I'm only adding year + week and I'm not getting what I desire. I would like to have '202101' if I change my code to '+3' because this year there are 53 weeks and the 54 week should 01.
(SELECT
LEFT(CONVERT(VARCHAR(10), GETDATE(), 120), 4) +
CAST((DATEPART(ISOWK, GETDATE()) + 3) AS NVARCHAR(2)))
I would like to be able to change my code like this
...GETDATE()) + 2) in my code should return 202053
...GETDATE()) + 3) in my code should return 202001
...GETDATE()) + 4) in my code should return 202002
etc...
Might it be that i should change my code and not have it as a 2 part YYYY and WW but rather combine it as a date? I would believe its a string now.
Hi I am creating a table in MS Access to store the details of children in a school.
I have a field called YearGroup which needs to calculate the school year they are in based on their date of birth and whether they have been moved up or down a year.
I.e. if the expression deems they are six years old they should be placed in year 2. If they were moved down or up a year they should be in year 1 or 3 (this is based on another field in the table called YearModifier).
The code I have at the moment is this:
Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier])
My problem is that Year(Now()) is returning as invalid expression. Lots of websites have recognised using the Now() function and also I've tried Date() but nothing seems to be accepted by Access (The version is 2010).
What is going on? How can I get today's date in a calculated field expression?
Thanks
Try creating a query with all of the fields from your table, and then add an extra field YearGroup: Year(Now()) - IIf(Month([DOB]) > 8, Year([DOB]) + 6 + [YearModifier], Year([DOB]) + 5 + [YearModifier])
It appears that Date functions can't be used in calculated columns in tables.
You could use this to get the year, which might work in field expressions:
format(date(),"yyyy")
About your function (which I have re-written very slightly)
Year( Now() )
- Year([DOB])
- IIf( Month([DOB]) > 8
, 6
, 5 )
+ [YearModifier]
however!
I don't think you want to use now(). Which year they are in depend on their age at the 1st Sept at the start of the current academic year not now! Ok now will work until 31/dec/2015, so I must assume you will not be using the function after this date!
If you are you must use 2015 not Now().
Ok?
You can calculate the age of the children with a simple function:
Public Function AgeSimple( _
ByVal datDateOfBirth As Date) _
As Integer
' Returns the difference in full years from datDateOfBirth to current date.
'
' Calculates correctly for:
' leap years
' dates of 29. February
' date/time values with embedded time values
'
' DateAdd() is used for check for month end of February as it correctly
' returns Feb. 28. when adding a count of years to dates of Feb. 29.
' when the resulting year is a common year.
' After an idea of Markus G. Fischer.
'
' 2007-06-26. Cactus Data ApS, CPH.
Dim datToday As Date
Dim intAge As Integer
Dim intYears As Integer
datToday = Date
' Find difference in calendar years.
intYears = DateDiff("yyyy", datDateOfBirth, datToday)
If intYears > 0 Then
' Decrease by 1 if current date is earlier than birthday of current year
' using DateDiff to ignore a time portion of datDateOfBirth.
intAge = intYears - Abs(DateDiff("d", datToday, DateAdd("yyyy", intYears, datDateOfBirth)) > 0)
End If
AgeSimple = intAge
End Function
Then your expression would be something like this (ignoring the modifier):
ClassYear: IIf(AgeSimple([DOB]) > 6, 2, 1)
I've seen threads where the document has Start Date and End Date "widgets" where users type in their dates, however, I'm looking for a dynamic solution, for example on the table below, when I select a date, say "1/1/2004", I only want to see active players (this would exclude Michael Jordan only).
Jersey# Name RookieYr RetirementYr Average PPG
23 Michael Jordan 1/1/1984 1/1/2003 24
33 Scotty Pippen 1/1/1987 1/1/2008 15
1 Derrick Rose 1/1/2008 1/1/9999 16
25 Vince Carter 1/1/1998 1/1/9999 18
The most flexible way is to IntervalMatch the RookieYr * RetireYr dates into a table of all dates. See http://qlikviewcookbook.com/recipes/download-info/count-days-in-a-transaction-using-intervalmatch/ for a complete example.
Here's the interval match for your data. You'll can obviously create your calendar however you want.
STATS:
load * inline [
Jersey#, Name, RookieYr, RetirementYr, Average, PPG
23, Michael Jordan, 1/1/1984, 1/1/2003, 24
33, Scotty Pippen, 1/1/1987, 1/1/2008, 15
1, Derrick Rose, 1/1/2008, 1/1/9999, 16
25, Vince Carter, 1/1/1998, 1/1/9999, 18
];
let zDateMin=37000;
let zDateMax=40000;
DATES:
LOAD
Date($(zDateMin) + IterNo() - 1) as [DATE],
year( Date($(zDateMin) + IterNo() - 1)) as YEAR,
month( Date($(zDateMin) + IterNo() - 1)) as MONTH
AUTOGENERATE 1
WHILE $(zDateMin)+IterNo()-1<= $(zDateMax);
INTERVAL:
IntervalMatch (DATE) load RookieYr, RetirementYr resident STATS;
left join (DATES) load * resident INTERVAL; drop table INTERVAL;
There's not much to it you need to load 2 tables one with the start and end dates and one with the calendar dates then you interval match the date field to the start and end field and from there it will work the last join is just to tidy up a bit.
The result of all of that is this ctrl-t. Don't worry about the Syn key it is required to maintain the interval matching.
Then you can have something like this.
Derrick Rose is also excluded since he had not started by 1/1/2004