home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!ames!agate!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bq035
- From: bq035@cleveland.Freenet.Edu (Brian Jepson)
- Newsgroups: comp.databases
- Subject: Re: Foxpro 2.0 Index Searches
- Date: 9 Jan 1993 18:46:05 GMT
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Lines: 47
- Message-ID: <1in6hdINN9bk@usenet.INS.CWRU.Edu>
- References: <thomasd.62.726343853@tps.COM>
- Reply-To: bq035@cleveland.Freenet.Edu (Brian Jepson)
- NNTP-Posting-Host: hela.ins.cwru.edu
-
-
- In a previous article, thomasd@tps.COM (Thomas W. Day) says:
-
- [stuff deleted]
-
- >4) Is there a reasonable way to perform math functions on 4-digit time
- >data? The data is derived by the TIME() function but is stored
- >in a character field as 99:99 (hour:minute) character data. What I want to
- >do is subtract two fields stored this way in each record and obtain the
- >average time between each of these fields. Obviously, 15:01-14.58 should
- >equal something other than 00:43. Is there a convert-text-to-time (CTOT?)
- >function?
- >
- This might be something like what you want. Calling syntax is:
- ?military("10:00AM")
- You will have to decide how to put the AM/PM indicator on there. It won't be
- too hard.
-
- *-
- *- takes a string variable of the form ##:##XX ie, 4:45pm, 5:30am
- *- and returns a string in military time (but in decimal), ie, 1675, 0550
- *-
- FUNCTION military
- PARAMETER t12
-
- t24 = ALLTRIM(STR(VAL(LEFT(t12,2)) + ;
- IIF(RIGHT(t12,2) = "AM", 0, 12))) + ;
- PADL(ALLTRIM(STR((VAL(SUBSTR(t12,4,2)) / 60) * 100)), 2, "0")
-
- IF LEFT(t24,2) = "12"
- t24 = STUFF(t24,1,2,"24")
- ELSE
- IF LEFT(t24,2) = "24"
- t24 = STUFF(t24,1,2,"12")
- ENDIF
- ENDIF
-
- RETURN VAL(t24)
-
- This should help out with your problem. Just be aware that 10:45 am = 1075.
- I don't have a routine to change it back, although that should be easy.
- Good luck!
- --
- * __ _____ Brian Jepson
- * /__) __ . __ __ / __ _ / _ __ iqm229@uriacc.uri.edu
- */___) / / (_// / (__/ (_/ /_) _) (_) / / bq035@freenet.cwru.edu
- * `- /
-