Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a date field that is the following format: 'MM/DD/YYYY h:mm:ss'
I want only the 'YYYY' portion.
This statement (subfield(DateBorn,'/',3) AS DateBorn) gives me 'YYYY h:mm:ss'
Is there a way to limit the subfield function to 4 digits so that it only gives me 'YYYY' ?
Hi Amber,
maybe
=SubField(SubField( 'MM/DD/YYYY h:mm:ss','/',3),' ')
Regards,
Antonio
May be this
Year(Date#(DateBorn, 'MM/DD/YYYY h:mm:ss'))
Why you need SubField over here. Can you use something like below
Year(Date#(DateFieldName,'MM/DD/YYYY hh:mm:ss'))
OR
SubField(SubField(DateFieldName, ' '),'/', -1)
However, why not
Year(DateField)
assuming Your Timestamp format is
SET TimestampFormat=MM/DD/YYYY h:mm:ss';
whatever type of field , to answer your question
"Is there a way to limit the subfield function to 4 digits"
use SubField + Left like this
Left(subfield(DateBorn,'/',3),4)
Regards,
Antonio
Hi
If is a date format, and is loaded in QV as date, you can use year(DateBorn)
Regards