Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to assign generations to people based on their date of birth. However everyone keeps showing up as other.
Where am I making a mistake?
load*,
If(date("Date of birth">=01/01/1946) and (Date("Date of birth"<=01/01/1964)), 'Baby Boomer',
If(Date("Date of birth">=01/01/1965) and (date("Date of birth"<=01/01/1976)), 'Generation X',
If(date("Date of birth">=01/01/1977) and (date("Date of birth"<=01/01/1995)), 'Generation Y',
If(date("Date of birth">=01/01/1996) and (date("Date of birth"<=27/01/2018)), 'Generation Z', 'other' )))) as Generation;
Thanks
try:
load*,
If(date("Date of birth")>='01/01/1946' and Date("Date of birth")<='01/01/1964', 'Baby Boomer',
If(Date("Date of birth")>='01/01/1965' and date("Date of birth")<='01/01/1976', 'Generation X',
If(date("Date of birth")>='01/01/1977' and date("Date of birth")<='01/01/1995', 'Generation Y',
If(date("Date of birth")>='01/01/1996' and date("Date of birth")<='27/01/2018', 'Generation Z', 'other' )))) as Generation;
Hi Robin,
Try this:
If(date("Date of birth")>=date(01/01/1946) and Date("Date of birth")<=date(01/01/1964), 'Baby Boomer',
If(Date("Date of birth")>=date(01/01/1965) and date("Date of birth")<=date(01/01/1976), 'Generation X',
If(date("Date of birth")>=date(01/01/1977) and date("Date of birth")<=date(01/01/1995), 'Generation Y',
If(date("Date of birth")>=date(01/01/1996) and date("Date of birth")<date(=27/01/2018), 'Generation Z', 'other' ))))
(in the number of ')' can be error, please correct it if needed)
G.
format looks wrong
i would suggest
date#("Date of birth") > date#('01/01/1946')
field name is case sensitive [] give inside the square bracket[Date of birth]
try:
load*,
If(date("Date of birth")>='01/01/1946' and Date("Date of birth")<='01/01/1964', 'Baby Boomer',
If(Date("Date of birth")>='01/01/1965' and date("Date of birth")<='01/01/1976', 'Generation X',
If(date("Date of birth")>='01/01/1977' and date("Date of birth")<='01/01/1995', 'Generation Y',
If(date("Date of birth")>='01/01/1996' and date("Date of birth")<='27/01/2018', 'Generation Z', 'other' )))) as Generation;
Hi Maniranjan,
you are right, field names are case sensitives, but [field name] and "field name" are equivalent.
G.
load*,
If(date("Date of birth",'MM/DD/YYYY')>='01/01/1946' and Date("Date of birth",'MM/DD/YYYY')<='01/01/1964', 'Baby Boomer',
If(Date("Date of birth",'MM/DD/YYYY')>='01/01/1965' and date("Date of birth",'MM/DD/YYYY')<='01/01/1976', 'Generation X',
If(date("Date of birth",'MM/DD/YYYY')>='01/01/1977' and date("Date of birth",'MM/DD/YYYY')<='01/01/1995', 'Generation Y',
If(date("Date of birth",'MM/DD/YYYY')>='01/01/1996' and date("Date of birth",'MM/DD/YYYY')<='27/01/2018', 'Generation Z', 'other' )))) as Generation;
Thank you very much all.