How do I get the date part from datetime variable ?

How do I get the date part from datetime variable ?

e.g
declare @start_time datetime

select @start_time = "10/31/2003"

This puts date and current System time into the variable.

I use this for some comparison on datetime field on database. But when I do
the comparison, I want to do the comparison without time part on database
field and my variable. How do I do that ?

Thanks


0
phari
12/5/2003 10:51:59 PM
sybase.ase.general 8655 articles. 0 followers. Follow

2 Replies
7742 Views

Similar Articles

[PageSpeed] 27
Get it on Google Play
Get it on Apple App Store

Check out the datepart function.

In article <3fd10c0f$1@forums-1-dub>, <phari> says...
> How do I get the date part from datetime variable ?
> 
> e.g
> declare @start_time datetime
> 
> select @start_time = "10/31/2003"
> 
> This puts date and current System time into the variable.
> 
> I use this for some comparison on datetime field on database. But when I do
> the comparison, I want to do the comparison without time part on database
> field and my variable. How do I do that ?
> 
> Thanks
> 
> 
> 
0
Mark
12/5/2003 11:00:13 PM
or CONVERT function (pay attention to third parameter)

example:
select convert(varchar(10),getdate(),112)
result:
20031208   -<-- YYYYMMDD

select convert(varchar(10),getdate(),108)
result:
17:40:30   -<--- HH:MM:SS

Regards,
    Andrew

"Mark Maslow" <mark.maslow@sierraclub.org> wrote in message
news:MPG.1a3aab35f3ce419896ef@forums.sybase.com...
> Check out the datepart function.
>
> In article <3fd10c0f$1@forums-1-dub>, <phari> says...
> > How do I get the date part from datetime variable ?
> >
> > e.g
> > declare @start_time datetime
> >
> > select @start_time = "10/31/2003"
> >
> > This puts date and current System time into the variable.
> >
> > I use this for some comparison on datetime field on database. But when I
do
> > the comparison, I want to do the comparison without time part on
database
> > field and my variable. How do I do that ?
> >
> > Thanks
> >
> >
> >


0
Andrew
12/8/2003 2:52:54 PM
Reply: