Hi,
i need to create a sql statement to find out record between a period, but i
only want to search with the date part only (e.g. 2006/1/23).
In my database, the type of the field is in datetime format. How can i
bypass the time part but still can find out what i need (e.g. 2006/1/23
00:00:00 - 2006/1/23 23:59:59)
sample SQL statement
select * from [table] where [datetime] between [fromdate] and [todate]
Apologies for non-good english, hope you get what i mean.
Thanks and Best Regards,
Sexball20060123 = 20060123 00:00
and
DATEADD(ss,-1,'20060124') = 20060123 23:59:59
select * from [table] where [datetime] between '20060123' and
DATEADD(ss,-1,'20060124')
HTH. Ryan
"sexball" <sexball@.sexball.com> wrote in message
news:%23vw7jBAIGHA.1192@.TK2MSFTNGP11.phx.gbl...
> Hi,
> i need to create a sql statement to find out record between a period, but
> i only want to search with the date part only (e.g. 2006/1/23).
> In my database, the type of the field is in datetime format. How can i
> bypass the time part but still can find out what i need (e.g. 2006/1/23
> 00:00:00 - 2006/1/23 23:59:59)
> sample SQL statement
> select * from [table] where [datetime] between [fromdate] and [todate]
> Apologies for non-good english, hope you get what i mean.
>
> Thanks and Best Regards,
> Sexball
>|||This will work,
SELECT getdate()
SELECT CAST(FLOOR(CAST( getdate() AS float)) AS DATETIME)
Thanks,
Sree
"sexball" wrote:
> Hi,
> i need to create a sql statement to find out record between a period, but
i
> only want to search with the date part only (e.g. 2006/1/23).
> In my database, the type of the field is in datetime format. How can i
> bypass the time part but still can find out what i need (e.g. 2006/1/23
> 00:00:00 - 2006/1/23 23:59:59)
> sample SQL statement
> select * from [table] where [datetime] between [fromdate] and [todate]
> Apologies for non-good english, hope you get what i mean.
>
> Thanks and Best Regards,
> Sexball
>
>|||Hi
You can try as:
select * from [table] where [datetime]
between cast([fromdate] as datetime) and cast([todate] as datetime)
I am not sure what you are looking for. But please let me know if this helps
you.
Please let me know if you have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"sexball" wrote:
> Hi,
> i need to create a sql statement to find out record between a period, but
i
> only want to search with the date part only (e.g. 2006/1/23).
> In my database, the type of the field is in datetime format. How can i
> bypass the time part but still can find out what i need (e.g. 2006/1/23
> 00:00:00 - 2006/1/23 23:59:59)
> sample SQL statement
> select * from [table] where [datetime] between [fromdate] and [todate]
> Apologies for non-good english, hope you get what i mean.
>
> Thanks and Best Regards,
> Sexball
>
>|||Thx Ryan, problem solved.
"Ryan" <Ryan_Waight@.nospam.hotmail.com> glsD:%23geO$GAIGHA.3056@.TK2MSFTNGP09.phx.
gbl...
> 20060123 = 20060123 00:00
> and
> DATEADD(ss,-1,'20060124') = 20060123 23:59:59
>
> select * from [table] where [datetime] between '20060123' and
> DATEADD(ss,-1,'20060124')
>
> --
> HTH. Ryan
> "sexball" <sexball@.sexball.com> wrote in message
> news:%23vw7jBAIGHA.1192@.TK2MSFTNGP11.phx.gbl...
>|||hi this
SELECT CONVERT(DATETIME,CONVERT(CHAR(10),GETDAT
E(),120),120)
?
"Chandra" <chandra@.discussions.microsoft.com> ะด?
news:6C1E767F-4026-4752-BA9F-5210A3274F81@.microsoft.com...
> Hi
> You can try as:
> select * from [table] where [datetime]
> between cast([fromdate] as datetime) and cast([todate] as datetime)
> I am not sure what you are looking for. But please let me know if this
helps
> you.
> Please let me know if you have any questions
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "sexball" wrote:
>
but i
No comments:
Post a Comment