Date = fhGetItemText(ptrFAM, '~.MARR.DATE:COMPACT')
I have searched, and perhaps I am missing it, misreading the doc available on this, but:
Date = fhGetItemText(ptrFAM, '~.MARR.DATE:YYYMMDD') doesn't appear to be available, in F,H on a computer, which is how underlyiing dates are usually stored to make for ordinal sort.
is there one or do I have to cut string and reverse, using the ABBREV3 or XDATE (dont remember which, I can look that up, the 12/12/1932 format?
* Date troubles.
Date troubles.
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28434
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Date troubles.
A significant problem with dates is that they may not not be just one day, and may be a year or a year & month.
Also Period and Range dates such as from 1914 to 1918 and between 1914 and 1918 are more complex.
How do you want to handle all those?
Use strDate = fhGetItemText(ptrIndi,'~.BIRT.DATE:ABBREV3') that uses the definition in Tools > Preferences > General tab Preferred Short Date Format that offers several in yyyy mm dd order.
But Period and Range dates will produce such as 1914-1918
Unfortunately, those formats omit leading zeros, e.g. 1900/8/1 is 1-Aug-1900 so don't sort correctly
So some gsub() conversions will need to insert those missing zeros.
An alternative is to use datDate = fhGetValueAsDate( fhGetItemPtr(ptrIndi,'~.BIRT.DATE') )
Then use it to buddy sort the text date.
Also Period and Range dates such as from 1914 to 1918 and between 1914 and 1918 are more complex.
How do you want to handle all those?
Use strDate = fhGetItemText(ptrIndi,'~.BIRT.DATE:ABBREV3') that uses the definition in Tools > Preferences > General tab Preferred Short Date Format that offers several in yyyy mm dd order.
But Period and Range dates will produce such as 1914-1918
Unfortunately, those formats omit leading zeros, e.g. 1900/8/1 is 1-Aug-1900 so don't sort correctly
So some gsub() conversions will need to insert those missing zeros.
An alternative is to use datDate = fhGetValueAsDate( fhGetItemPtr(ptrIndi,'~.BIRT.DATE') )
Then use it to buddy sort the text date.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: Date troubles.
ok, thats sort of what I had gleaned out of it. ABBREV3 and cut and reverse it, installing leading zeros as needed,
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28434
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Date troubles.
You don't have to cut and reverse if you set Preferred Short Date Format as I suggested to say yyyy/mm/dd.
BUT also note what I said about Period and Range dates.
Anyway you don't have to cut & reverse as it can all be done with gsub().
If the format is dd/mm/yyyy then use:
Date = Date:gsub("^(%d+)/(%d+)/(%d+)$","%3/%2/%1")
and then use the Date:gsub() below to insert leading zeros.
Another option is shown below but will return nothing for most Period and Range dates:
local Year = fhGetItemText(ptrIndi,'~.BIRT.DATE:YEAR')
local Month = fhGetItemText(ptrIndi,'~.BIRT.DATE:MONTH_NUMBER')
local Day = fhGetItemText(ptrIndi,'~.BIRT.DATE:DAY')
local Date = Year.."/"..Month.."/"..Day
Date = Date:gsub("/(%d)/","/0%1/")
Date = Date:gsub("/(%d)$","/0%1")
OR as I said use a Buddy sort which works for ALL types of date.
BUT also note what I said about Period and Range dates.
Anyway you don't have to cut & reverse as it can all be done with gsub().
If the format is dd/mm/yyyy then use:
Date = Date:gsub("^(%d+)/(%d+)/(%d+)$","%3/%2/%1")
and then use the Date:gsub() below to insert leading zeros.
Another option is shown below but will return nothing for most Period and Range dates:
local Year = fhGetItemText(ptrIndi,'~.BIRT.DATE:YEAR')
local Month = fhGetItemText(ptrIndi,'~.BIRT.DATE:MONTH_NUMBER')
local Day = fhGetItemText(ptrIndi,'~.BIRT.DATE:DAY')
local Date = Year.."/"..Month.."/"..Day
Date = Date:gsub("/(%d)/","/0%1/")
Date = Date:gsub("/(%d)$","/0%1")
OR as I said use a Buddy sort which works for ALL types of date.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry