codetoad.com
  ASP Shopping Cart, Forum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  maximum and minimum of two time  Archive Import (diego) at 02:55 on Monday, July 14, 2003
 

how to get the maximum and minimum of two dates

sample
the value of time1(variable) is 8:00 AM
the value of time2(variable) is 5:48 PM

i want to get the minimum and maximum of two time
corect me if i am wrong

"Select Timein,Timeout from WorkSchedule where Timein >="&time1&" and Timeout <="& time2

am i correct?

thanks,
Pls. help
this is impt.

  Re: maximum and minimum of two time  Archive Import (david) at 09:20 on Monday, July 14, 2003
 

use datediff

  Re: maximum and minimum of two time  Archive Import (diego) at 20:05 on Monday, July 14, 2003
 

how

  Re: maximum and minimum of two time  Troy Wolf at 14:41 on Tuesday, July 15, 2003
 

Your post is titled "maximum and minimum", but your query has nothing to do with MAX and MIN. Your query:

"Select Timein,Timeout from WorkSchedule where Timein >="&time1&" and Timeout <="& time2

Will give you all records that apply -- not the single MAX or MIN. If this is what you want, then you are done.

If what you are doing is not what you want, then I need to know more specifically what you want. Here is how you could return the columns for the record with the earliest Timein that also falls within your Time1 to Time2 range. (This would be Minimum Timein that applies.)

sql = "select *" & _
" from WorkSchedule" & _
" where Timein = (" & _
" select MIN(Timein)" & _
" from WorkSchedule" & _
" where Timein >= `" & time1 "`" & _
" and Timeout <= `" & time2 & "`" )
" and Timeout <= `" & time2 & "`"

It aint pretty, but that`s a way to do it. To find the MAX record, you`d adjust this same query accordingly. So you`d run 2 queries. One to get the MIN record and one to get the MAX record.
Troy Wolf: site expert
SnippetEdit Website Editor









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  matrix addition
•  Re: Storing data from HTML to Excel or TXT
•  Re: function within loop problem
•  Re: Ô‡´ò¥¯¥é¥Ö¤Ã� ¥Æ©`¥é©`¥á¥¤¥É£ò£±£±¥¢¥¤¥¢¥ó ¤Î£··¬ ¤Ç¤¹
•  Re: Replace
•  Re: タイトリスト AP2アイアン 712ã�®æƒ…å �
•  Re: SMS from Perl using HTTP request
•  Re: Charl Schwartzel
•  Re: Adhyayan - Annual Student Conference and Online Coding Festival


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2013