how to get just the date?

S

Smokey Grindle

this is one thing that has always annyoed me in SQL is the lack of ability
to get just the date of a datetime field... with SQL Server 2005 is there
any easy and fast way to compare a date against another date excluding the
time? thanks!
 
Z

zacks

this is one thing that has always annyoed me in SQL is the lack of ability
to get just the date of a datetime field... with SQL Server 2005 is there
any easy and fast way to compare a date against another date excluding the
time? thanks!

This is really a question for the SQL Server group, but here is how I
isolate the date part of a SQL Datatime column:

left(convert(varchar, datetimecolumnname, 120), 10)

This is a SQL command, NOT a VB.NET command!!!

This results in a date value in the format: YYYY-MM-DD.
 
S

Smokey Grindle

actually I posted it to the SQL group *scratches head* not sure how it ended
up here
 
R

Rad [Visual C# MVP]

this is one thing that has always annyoed me in SQL is the lack of ability
to get just the date of a datetime field... with SQL Server 2005 is there
any easy and fast way to compare a date against another date excluding the
time? thanks!
What you need is the convert function. You can pass as a parameter one
of the formats that give you date only. Details are in SQL Server
books online
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top