home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / 8966 < prev    next >
Encoding:
Internet Message Format  |  1993-01-09  |  2.0 KB

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