Wednesday, March 21, 2012

DATETIME QUESTION

Is there any command like DateTime.Today (c#) which returns 19.06.2006
00:00:00
it makes zero hour,minutes and second..Savas
SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT))AS DATETIME)
"Savas Ates" <in da club> wrote in message
news:Ow3oq25kGHA.3936@.TK2MSFTNGP05.phx.gbl...
> Is there any command like DateTime.Today (c#) which returns 19.06.2006
> 00:00:00
> it makes zero hour,minutes and second..
>
>|||The most efficient way I've found is to use the datetime functions.
SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, DateTimeColumn))
FROM SomeTable;
"Savas Ates" <in da club> wrote in message
news:Ow3oq25kGHA.3936@.TK2MSFTNGP05.phx.gbl...
> Is there any command like DateTime.Today (c#) which returns 19.06.2006
> 00:00:00
> it makes zero hour,minutes and second..
>
>|||Her's one:
select convert(datetime, convert(varchar(64), getdate(), 112), 112)
ML
http://milambda.blogspot.com/|||I have one morequestion
I have some records
2006-06-17 14:17:28.000
2006-06-17 15:17:28.000
2006-06-17 16:17:28.000
I want to have count number of the records if they have same they .
SELECT COUNT(Referer_IP),Referer_time FROM TBL_REFERER GROUP BY Referer_Time
I wrote that query but it doesnt work ..I think i calculates hour,minute
and second information too.
My problem is that i want to group by them which have same day not caring
about hour ,minute information ?|||One way combining: 2 styles, change getdate() to your column name
SELECT CONVERT(VARCHAR(10),GETDATE(),104) + ' '+
CONVERT(VARCHAR(8),DATEADD(DAY, 0, DATEDIFF(DAY, 0, getdate())) ,108)
or Just this
SELECT CONVERT(VARCHAR(10),GETDATE(),104) + ' 00:00:00'
Denis the SQL Menace
http://sqlservercode.blogspot.com/
Savas Ates wrote:
> Is there any command like DateTime.Today (c#) which returns 19.06.2006
> 00:00:00
> it makes zero hour,minutes and second..|||Well, you need to use one of the calculations provided to you, not
Referer_time.
SELECT
CONVERT(CHAR(10), Referer_Time, 120),
COUNT(*)
FROM
dbo.TBL_REFERER
GROUP BY
CONVERT(CHAR(10), Referer_Time, 120);
"Savas Ates" <in da club> wrote in message
news:%23x%23FdB6kGHA.4816@.TK2MSFTNGP05.phx.gbl...
>I have one morequestion
> I have some records
> 2006-06-17 14:17:28.000
> 2006-06-17 15:17:28.000
> 2006-06-17 16:17:28.000
> I want to have count number of the records if they have same they .
> SELECT COUNT(Referer_IP),Referer_time FROM TBL_REFERER GROUP BY
> Referer_Time
> I wrote that query but it doesnt work ..I think i calculates hour,minute
> and second information too.
> My problem is that i want to group by them which have same day not caring
> about hour ,minute information ?
>
>|||Hi
Take a look at DATEPART system function
"Savas Ates" <in da club> wrote in message
news:%23x%23FdB6kGHA.4816@.TK2MSFTNGP05.phx.gbl...
>I have one morequestion
> I have some records
> 2006-06-17 14:17:28.000
> 2006-06-17 15:17:28.000
> 2006-06-17 16:17:28.000
> I want to have count number of the records if they have same they .
> SELECT COUNT(Referer_IP),Referer_time FROM TBL_REFERER GROUP BY
> Referer_Time
> I wrote that query but it doesnt work ..I think i calculates hour,minute
> and second information too.
> My problem is that i want to group by them which have same day not caring
> about hour ,minute information ?
>
>|||I also need to have WHERE CLAUSE IN my query..
SELECT
CONVERT(CHAR(10), Referer_Time, 120),
COUNT(*)
FROM
dbo.TBL_REFERER
GROUP BY
CONVERT(CHAR(10), Referer_Time, 120) ,Referer_Time
HAVING Referer_Time>DateADd (d,-5,Referer_Time)
I wrote That it returns wrong results...|||>I also need to have WHERE CLAUSE IN my query..
Can you give us a full spec/requirement instead of adding individual things
you "need"? I feel like E.T. following a trail of reese's pieces.

> SELECT
> CONVERT(CHAR(10), Referer_Time, 120),
> COUNT(*)
> FROM
> dbo.TBL_REFERER
> GROUP BY
> CONVERT(CHAR(10), Referer_Time, 120) ,Referer_Time
> HAVING Referer_Time>DateADd (d,-5,Referer_Time)
> I wrote That it returns wrong results...
What are "wrong results"? Can you show DDL, sample data, and desired
output? Please follow guidelines in http://www.aspfaq.com/5006

No comments:

Post a Comment