Tuesday, March 27, 2012

Date query problem!

Hi,
I've a problem with making a query. I need to get out a result where a date
for example 25-02-05 is in a table.
The problem is that the dates in the table are old like 25-02-03. So is
there a sollution where I only need the day and month to get the result?
Thanks,
FredIf I inderstood, you want to see if there is a row for a specific month and
day.
declare @.d datetime
set @.d = '20050225'
select * from t where month(colA) = month(@.d) and day(colA) = day(@.d)
go
AMB
"news.wanadoo.nl" wrote:

> Hi,
> I've a problem with making a query. I need to get out a result where a dat
e
> for example 25-02-05 is in a table.
> The problem is that the dates in the table are old like 25-02-03. So is
> there a sollution where I only need the day and month to get the result?
> Thanks,
> Fred
>
>|||news.wanadoo.nl wrote:
> Hi,
> I've a problem with making a query. I need to get out a result where a dat
e
> for example 25-02-05 is in a table.
> The problem is that the dates in the table are old like 25-02-03. So is
> there a sollution where I only need the day and month to get the result?
--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
By "old" do you mean the dates are stored as strings in the format "25
02-03," or, do you mean the dates are in the past, in the year 2003,
instead of the year 2005?
Assuming (a lot) that the dates are stored as DateTime data types:
SELECT *
FROM table_name
WHERE date_column = '20050225'
Normally, a query's WHERE clause filters which records are selected from
a table. Read the Books On Line (BOL) articles on the WHERE clause.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQh+P24echKqOuFEgEQLt9gCeOV3ZFXBu+JAp
CbMNi+I5rS4w104AoMBB
kpwTK1OPe8MZP/XAsyfoSRDb
=KstK
--END PGP SIGNATURE--|||These dates are old and are in the DateTime type.
So what I need is an WHERE clause that can select also the old dates. With a
input date that is in 2005! Is this possible?
Thx
"MGFoster" <me@.privacy.com> wrote in message
news:rdMTd.5740$873.3054@.newsread3.news.pas.earthlink.net...
> news.wanadoo.nl wrote:
> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> By "old" do you mean the dates are stored as strings in the format "25
> 02-03," or, do you mean the dates are in the past, in the year 2003,
> instead of the year 2005?
> Assuming (a lot) that the dates are stored as DateTime data types:
> SELECT *
> FROM table_name
> WHERE date_column = '20050225'
> Normally, a query's WHERE clause filters which records are selected from
> a table. Read the Books On Line (BOL) articles on the WHERE clause.
> --
> MGFoster:::mgf00 <at> earthlink <decimal-point> net
> Oakland, CA (USA)
> --BEGIN PGP SIGNATURE--
> Version: PGP for Personal Privacy 5.0
> Charset: noconv
> iQA/ AwUBQh+P24echKqOuFEgEQLt9gCeOV3ZFXBu+JAp
CbMNi+I5rS4w104AoMBB
> kpwTK1OPe8MZP/XAsyfoSRDb
> =KstK
> --END PGP SIGNATURE--|||Yes. See my post below. The WHERE clause shows how to select for the
date 25 Feb 2005. The date format is YYYYMMDD.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
news.wanadoo.nl wrote:
> These dates are old and are in the DateTime type.
> So what I need is an WHERE clause that can select also the old dates. With
a
> input date that is in 2005! Is this possible?
> Thx
> "MGFoster" <me@.privacy.com> wrote in message
> news:rdMTd.5740$873.3054@.newsread3.news.pas.earthlink.net...
>
>
>sql

No comments:

Post a Comment