Home > Archive > MS SQL Server > October 2006 > Converting time to day









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Converting time to day
jack.smith.sam@gmail.com

2006-10-24, 6:37 pm

Hi All,

I am pretty new to sql server. I have a table with a column which has
data in form of time,e.g.:
2006-10-15 08:06:29.000

I want to select data from the table using only date part of the time
(I want to group the data by day)
Can you please help me?

Thanks.

Dave Patrick

2006-10-24, 6:37 pm

You can use the Floor() function.

http://msdn2.microsoft.com/en-us/library/ms178531.aspx

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

<jack.smith.sam@gmail.com> wrote:
| Hi All,
|
| I am pretty new to sql server. I have a table with a column which has
| data in form of time,e.g.:
| 2006-10-15 08:06:29.000
|
| I want to select data from the table using only date part of the time
| (I want to group the data by day)
| Can you please help me?
|
| Thanks.
|


Sue Hoegemeier

2006-10-24, 6:37 pm

You can use CONVERT to change datetime formats. To return or
group by just the date, something along the lines of:
convert(char(10), YourDateColumn, 101)

-Sue

On 15 Oct 2006 17:55:47 -0700, jack.smith.sam@gmail.com
wrote:

>Hi All,
>
>I am pretty new to sql server. I have a table with a column which has
>data in form of time,e.g.:
>2006-10-15 08:06:29.000
>
>I want to select data from the table using only date part of the time
>(I want to group the data by day)
>Can you please help me?
>
>Thanks.


Dan Guzman

2006-10-24, 6:37 pm

One method is with DATEADD/DATEDIFF:

SELECT DATEADD(day,0,DATEDI
FF(day,0,('20061015 08:06:29.000')))

--
Hope this helps.

Dan Guzman
SQL Server MVP
<jack.smith.sam@gmail.com> wrote in message
news:1160960147.761712.173580@i42g2000cwa.googlegroups.com...
> Hi All,
>
> I am pretty new to sql server. I have a table with a column which has
> data in form of time,e.g.:
> 2006-10-15 08:06:29.000
>
> I want to select data from the table using only date part of the time
> (I want to group the data by day)
> Can you please help me?
>
> Thanks.
>


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com