Filemaker Convert DD MM SS TO DD.DDD - latitude-longitude

I am trying to convert the following fields:
LAT SS
LAT MM
LAT DD
to LATITUDE DD.DDD
LONG SS
LONG MM
LONG DD
to LONGITUDE DD.DDD
I've tried with a script but with NO resolve.
Dumped Vehicle::LATITUDE=(Dumped Vehicle::LAT SS/3600)+(Dumped Vehicle::LAT MM/60)+Dumped Vehicle::LAT DD
What am I doing wrong?
My idea was the user would enter the DD MM SS and the script would calculate during the entry of any of the fields upon exit or save of each field.

You don't need a script for this - only calculation fields.
The basic formula to convert latitude or longitude given as degrees, minutes and seconds to decimal degrees is:
degrees + minutes / 60 + seconds / 3600
However, to determine the sign of the result, you also need to know the direction: North or South for the latitude, East or West for the longitude. I don't see that you have a field for that.

Related

Format timespan with hours going above 24 instead of using a days part

In Visual Basic .NET, I am trying to convert time elapsed in seconds to hh:mm:ss format which can go over 24 hours.
As an example, when try to convert 86400 seconds to a timespan with the following code:
dim sec = 86400
dim res = TimeSpan.FromSeconds(sec).ToString
the output is "1.00:00:00"
while the desired output for me is "24:00:00"
How is it possible to do so?
You just need to do the calculation:
Dim secs = 86400
Dim ts = TimeSpan.FromSeconds(secs)
Dim res = String.Format("{0}:{1:00}:{2:00}", (ts.Days * 24 + ts.Hours), ts.Minutes, ts.Seconds)
Console.WriteLine(res)
Outputs:
24:00:00
If you want at least two digits for the hours, use "{0:00}:{1:00}:{2:00}".
(You could use String.Format("{0}:{1:00}:{2:00}", Math.Floor(ts.TotalHours), ts.Minutes, ts.Seconds) if you think it looks better.)
What you ask isn't available either as a standard or custom format.
You want to emit the total hours as a rounded-down integer followed by the minutes and seconds part. The custom format specifiers only work for specific parts.
You can use the TimeSpan.TotalHours property to retrieve the hours as a double and format the rest of the string using custom specifiers.
Dim ts=TimeSpan.FromDays(1)
String.Format("{0:00}:{1:mm\:ss}",Math.Floor(ts.TotalHours), ts)
Or
Dim ts=TimeSpan.FromSeconds(61)
String.Format("{0:00}:{1:mm\:ss}",Math.Floor(ts.TotalHours), ts)

Values vary after conversion from excel

I am trying to get values from one of the column from excel and i am facing strange issue that i cannot overcome so far.
Excel cells text we working on
Column format is set to: [h]:mm:ss so means hours could exceed 12/24.
When i am getting that values they are in double format as excel probbaly stores it in that way therefore i decided to write function to convert it back again to hours, minutes and seconds so i did that function:
Public Shared Function parseExcelHour(cellInput As String) As String
Dim excelHour As Double = 0
Dim hour As Integer
Dim min As Integer
Dim sec As Integer
Try
excelHour = [Double].Parse(cellInput)
Catch
End Try
sec = CInt((excelHour * 1440 * 60) Mod 60)
min = CInt((excelHour * 1440) Mod 60)
'mod (%) takes only the remainder as an int (if 5/4 = 1.25 , % only takes the number 1 that cannot be divided into an integer)
hour = CInt((excelHour * 1440) / 60)
' with the int cast you get only an integer.
Return hour & ":" & min & ":" & sec
End Function
However when i see the results, they are vary between excel and what i get after conversion. For three of them hours are either -1 or +1 if you compare. Also in one case we have additional + 1 minute. I suppose there is wrong hour calculation but i could be in wrong. See on screeshoot:
Results
Does anyone knows why i got those differences? Is that because i am missing something within my method or something else.
Excel stores a full Datetime equivalent as one double. The part before the decimal point is the days (since 1.1.1900; 1.1.1904 on Mac; note the bug that 1900 is faultily cosnider a leap year in Excel).
The part after is the time of the day, wich is what you apparently want:
https://stackoverflow.com/a/981865/3346583
What you are seeing in excel is meerely a ToString Foramting of the double value. Same way DateTime.ToString() would give you a string representation of whatever value is actually stored (most often a realy big unsigned int, with the ticks since a date).
A difference in full hours sounds like it might be a Timezone issue. But I am not aware that Excel stores Timezones in the first place (or what default timezone it asumes).

Convert Float value to Hours and Minutes

I have a float value, for example 0.999888, which I am getting from SQL database.
I have a variable in vbscript assigned to the float value from the SQL.
Lets say that I have this, for example
Dim TimeInFloat
TimeInFloat = 0.999888
I want to convert it to the hours and minutes either in SQL itself or VBscript.
Any suggestions?
You can convert it to hours and minutes in SQL by doing:
select floor(TimeInFloat * 24) as hours,
60 * (TimeInFloat * 24 - floor(TimeInFloat * 24)) as minutes
You can do similar logic in VBA.
In VBScript the CDate function allows you to convert float/double to time:
>>> WScript.Echo CDate(0.999888)
23:59:50

Format type of GPS data

While getting GPS data from a receiver I get it in this format 4119.03283,7203.39095. Does anybody know what kind of format that is? I just can't get my mind around what format this is like is it DMS, Decimal?
The format is called DM (Degrees and decimal minutes).
4119.03283,7203.39095
is 41° and 19.03283 minutes (the first two digits in latitude),
same for
7203.39095: 72° 3.39095' (attention here: it should be 3 digits for longitude: so 07203.39095, check if you have 5 digits before comma, then the first 3 are degrees, else the first 2 are degrees. check further for missing leading zerors)
to convert to decimal degrees (format name DEG): 72 + 3.39095 / 60.0

Convert time to float

What would be the best algorithm / code to convert time to float? I'm doing this in Obj-c but really all I need is an algorithm and I can make the code from there.
EX:
1:30am to 1.50
2:15pm to 14.25
5:45pm to 17.75
EDIT:
My time format is minutes since midnight.
You can parse the string to get two int numbers and an am/pm part (h, m, and a), and then calculate the fraction as follows:
int h, m, a;
// set a to 0 for "am", or 1 for "pm"
float time = 60*(a*12+h)+m;
float res = time / 60.0;
How about NSDate timeIntervalSinceDate? And divide by 3600, of course.
Or, for time within a single day, use NSDateFormatter with an "A" date format to produce milliseconds since midnight, then mash on that.