SQL and times

Results 1 to 2 of 2

Thread: SQL and times

  1. #1
    Join Date
    Dec 1969

    Default SQL and times

    How can I subtract one minute from a time in a SQL statement. For example......AND ((Schedule.Sched_Time = #" & Exp_Time & "#)...where Exp_Time is in the format '10:00:00 AM'. I don't have to do this in the SQL code, I could could subtract the minute from Exp_Time before the code, it doesn't matter. Either way, I've tried Exp_time - 00:01:00and other variations without any success. Any help would be great! Thanks ahead of time, Jay
    spanish girl Webcams
    Last edited by Jay; 04-16-2011 at 01:25 AM.

  2. #2
    Join Date
    Dec 1969

    Default *ACCESS* and times...

    Since I see you using #...#, I conclude you are using Access. The answer I give you is for Access, because Access is built on top of VBA, a kin of VBS.<BR><BR>Anyway...<BR><BR>The secret is the DateAdd function.<BR><BR>In VBScript, you do: <BR><BR>&#060;%<BR>oneMinuteEarlier = DateAdd("n", -1, theStartingTime)<BR>%&#062;<BR><BR>(you use "n" instead of "m" because "m" means "month" so they had to pick something reasonable for "miNute")<BR><BR>Or, in your code,<BR><BR>"...AND Schedule.Sched_Time = #" & DateAdd("n",-1,Exp_Time) & "# ..."<BR><BR>The fun part is...you can do the same thing in Access. We&#039;ll do it in reverse here:<BR><BR>"...AND DateAdd(&#039;n&#039;,1,Schedule.Sched_Time) = #" & Exp_Time & "# ..."<BR><BR>*** NOW *** <BR><BR>I have one big problem with that: What happens if the Sched_Time is 10:00:17 AM and Exp_Time is 10:01:12 AM ???<BR><BR>Do you *really* mean to use = to check the time match??? Shouldn&#039;t you be using &#062;= or &#060;= or maybe even BETWEEN???<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts