Hi,
I've looked for this in the help but just can't find it...
I'm trying to format the result from LastUpdated (a datepoint) to include the time. I then store this information in my external DB.
I tried using:
dpLastUpdated = fhCallBuiltInFunction('LastUpdated', pi)
LastUpdated = string.format('%d %b %y %H:%S', dpLastUpdated)
But that doesn't work. I got the message: bad argument #2 to 'format' (number expected, got userdata). So I guess string.format doesn't understand datepoints.
I appreciate your help with this.
Shosh
* Formatting date point to include time
-
shoshk
- Famous
- Posts: 242
- Joined: 13 May 2015 16:28
- Family Historian: V7
- Location: Mitzpe Jericho, Israel
Formatting date point to include time
Shosh Kalson
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Formatting date point to include time
Hi Shosh.
There are a few new features in FH V6 that have not been documented, and this is one of them.
Calico Pie have been informed, but probably have more important matters to sort out.
In this case the details are:
Understanding Functions > LastUpdated
Now returns Date + Time but is undocumented.
Date parts can be extracted using Date(LastUpdated(%INDI%)) or Year(LastUpdated(%INDI%)), etc, but how is Time extracted?
If used in Plugins via fhCallBuiltInFunction it returns three parameters:
DatePoint, IntegerHour, IntegerMinute = fhCallBuiltInFunction("LastUpdated",ptrRec)
You are correct that string.format() does not understand the FH internal DatePoint format.
The FH Plugin Help > The FH API > Objects > Datept section explains the available methods.
In this case use:
IntegerDay = DatePoint:GetDay()
IntegerMonth = DatePoint:GetMonth()
IntegerYear = DatePoint:GetYear()
then with a 'C' printf style format string:
LastUpdated = string.format("%02d %02d %04d %02d:%02d", IntegerDay,IntegerMonth,IntegerYear,IntegerHour,IntegerMinute)
There are a few new features in FH V6 that have not been documented, and this is one of them.
Calico Pie have been informed, but probably have more important matters to sort out.
In this case the details are:
Understanding Functions > LastUpdated
Now returns Date + Time but is undocumented.
Date parts can be extracted using Date(LastUpdated(%INDI%)) or Year(LastUpdated(%INDI%)), etc, but how is Time extracted?
If used in Plugins via fhCallBuiltInFunction it returns three parameters:
DatePoint, IntegerHour, IntegerMinute = fhCallBuiltInFunction("LastUpdated",ptrRec)
You are correct that string.format() does not understand the FH internal DatePoint format.
The FH Plugin Help > The FH API > Objects > Datept section explains the available methods.
In this case use:
IntegerDay = DatePoint:GetDay()
IntegerMonth = DatePoint:GetMonth()
IntegerYear = DatePoint:GetYear()
then with a 'C' printf style format string:
LastUpdated = string.format("%02d %02d %04d %02d:%02d", IntegerDay,IntegerMonth,IntegerYear,IntegerHour,IntegerMinute)
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
-
shoshk
- Famous
- Posts: 242
- Joined: 13 May 2015 16:28
- Family Historian: V7
- Location: Mitzpe Jericho, Israel
Re: Formatting date point to include time
Mike,
Thank you. That's exactly what I was looking for. Glad to know it was added to FH.
Shosh
Thank you. That's exactly what I was looking for. Glad to know it was added to FH.
Shosh
Shosh Kalson