Database Reference
In-Depth Information
UP TO SPEED: FROM NUMBERS TO TIMES
If you can treat dates and times like numbers, then it makes sense that you can go the other way, too.
Suppose you have a field called Race Time that holds each athlete's race time as a number of
seconds. If you'd rather view this time in the Hours:Minutes:Seconds (or Minutes:Seconds) format,
then you can easily use a calculation to convert it to a time value:
GetAsTime(Race Time)
When you pass it a number value, the GetAsTime() function converts that number into the equival-
ent time. (If you view the field on a layout, then you can use the time formatting options to display
hours, minutes, and seconds in just about any way you want, as shown on Short System Date and
Long System Date . ) The GetAsTime() function has another purpose: It can convert text values into
times. If someone puts “3:37:03” into a text field, you can use GetAsTime() to convert that text into
a valid time value.
FileMaker has GetAsDate() and GetAsTimestamp() functions, too, which work just the same.
To get a time of day value in the future or past, add or subtract the number of seconds or a
time value. Suppose you have a database of movie show times for your theater business. You
use a timestamp field to record the date and time when each showing starts. You also use a
time field to keep track of each movie's length. Now you need to know when each movie
ends :
Showtime + Duration
NOTE
If you store the date and time the movie starts in separate date and time fields, then the movie time
calculation is much more difficult. Suppose a movie starts at 11:30 p.m. (23:30 in 24 hour notation)
and runs for 2 hours. Adding these together, you get 25:30, a perfectly valid time value, but not a
valid time of day . When you add to time values, they don't “roll over” after midnight. Timestamps,
on the other hand, work as expected: You get 1:30 a.m. on the next day.
▪ You can subtract one timestamp value from another. The result will be given in seconds,
so you'll have to do more math on the result to get minutes or hours. For example, you
use timestamps to record the start and finish times for a job. To find out how long the job
took, in minutes, use this calculation:
(Finish Time Stamp-Start Time Stamp) / 60
▪ To increase or decrease a time duration value, add or subtract the number of seconds or
another time duration. Say you have a related Songs table with a Song Lengths field to
Search WWH ::




Custom Search