|
Mike;
If the table where your YY MM DD date is stored contains a single record,
as your sql implies, then I would create a view:
Create View PeriodOpenDate
SELECT DATE(CONCAT('20', CONCAT(YY, CONCAT('-', CONCAT( MM,
(CONCAT('-', DD))))))) as openDate FROM LIB/FILE;
Duane Christen
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:
midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Mike Wills
Sent: Wednesday, February 09, 2011 3:39 PM
To: midrange-l@xxxxxxxxxxxx
Subject: To function or not to function, that is the question at hand
I am working on some SQL statements for an ASP.NET application. One of the
things that is required is to only display information in an open period.
The period is updated automatically by the vendor software as the previous
period is closed. So I finding myself doing a bunch of sub selects like:
where date >= (SELECT DATE(CONCAT('20', CONCAT(YY, CONCAT('-', CONCAT( MM,
(CONCAT('-', DD))))))) FROM LIB/FILE')
Yes, each portion of the date is in separate fields.
Would making this query a function make the query more efficient? I have
never created a function before how would I do that? My thought is having
something like:
IsInRange(date)
So I can do "WHERE IsInRange(date)".
Or is there a better way?
--
Mike Wills
http://mikewills.me
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.