Re: simple SQL query question

Josh Hillman ( (no email) )
Mon, 24 Mar 1997 11:48:24 -0500

Peter,
With the exception of a pretty minor typo, your bio-memory serves you
well--it worked just fine.

The typo was in the 4th line below--it should have been "@enddate" instead
of "@startdate"

> DECLARE @startdate char(20)
> SELECT @startdate = 'Mar 17 1997 12:00AM'
> DECLARE @enddate char(20)
> SELECT @startdate = 'Mar 24 1997 12:00AM'

Thanks a lot for this simple solution--I'll be able to use this in many of
my statistical scripts!

Josh Hillman
hillman@talstar.com

----------
From: Peter A. Sang <pesa@sang.de>
To: 'ntisp@emerald.iea.com'
Subject: AW: simple SQL query question
Date: Monday, March 24, 1997 11:11 AM

Josh,
a SELECT out of my bio-memory :)

DECLARE @startdate char(20)
SELECT @startdate = 'Mar 17 1997 12:00AM'
DECLARE @enddate char(20)
SELECT @startdate = 'Mar 24 1997 12:00AM'
[...]
>select somecolumns
>from sometable
>where date > @startdate
>and date < @enddate

_should_ do the job....

Hope it helps!

cu, Peter

-
Peter A. Sang
SANG Computersysteme GmbH * Kruppstr. 82-100 * 45145 Essen * Germany
T: +49-201-82020-0 * F:-40 * http://sang.net * mailto:pesa@sang.net
* Microsoft Solution Provider * Intel Systems Integrator *

>----------
>Von: Josh Hillman[SMTP:admin-maillist@talstar.com]
>Gesendet: Montag, 24. März 1997 16:44
>An: ntisp@emerald.iea.com
>Betreff: simple SQL query question
>
>When executing a SQL query that has many mentions of the same dates/times
>throughout it, can that date be replaced by "variable"? In other words
>something like this:
>
>startdate = "Mar 17 1997 12:00AM"
>enddate = "Mar 24 1997 12:00AM"
>
>select somecolumns
>from sometable
>where date > startdate
>and date < enddate
>
>select someothercolumns
>from someothertable
>where date > startdate
>and date < enddate
>
>
>
>This is no big deal if the dates are only mentioned once, but if the same
>ones are all over the place and the dates need to be adjusted from week to
>week, redoing all the dates can drive me crazy...
>
>Thanks for any insight,
>
>Josh Hillman
>hillman@talstar.com