Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DATE function error

Author  Topic 

kiddofatso
Starting Member

5 Posts

Posted - 2014-10-07 : 02:13:27
Hi Everyone......while using following function I am getting this Error "Msg 195, Level 15, State 10, Line 1
'DATE' is not a recognized built-in function name."

select callid, DATE(segstart) AS calldate
from October_CLI.dbo.raw
Where callid >0


Segstart Column = Data with call date & time

Callid Column = Unique Call Id

October_CLI.dbo.raw = Table

Calldate = Where i want the only date to be capture from segstart column

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2014-10-07 : 02:35:42
Try this:

select callid, DATEADD(dd, 0, DATEDIFF(dd, 0, segstart)) AS calldate
from October_CLI.dbo.raw
Where callid >0




Harsh Athalye
http://in.linkedin.com/in/harshathalye/
Go to Top of Page

kiddofatso
Starting Member

5 Posts

Posted - 2014-10-07 : 02:38:09
It works thanks a ton
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-10-07 : 06:48:50
[code]SELECT CallID,
CAST(SegStart AS DATE) AS CallDate
FROM [October_CLI].dbo.[Raw]
WHERE CallID > 0;[/code]


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2014-10-07 : 07:03:57
quote:
Originally posted by SwePeso

SELECT	CallID,
CAST(SegStart AS DATE) AS CallDate
FROM [October_CLI].dbo.[Raw]
WHERE CallID > 0;



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA



That will work assuming database is on SQL Server 2008 or later version.

Harsh Athalye
http://in.linkedin.com/in/harshathalye/
Go to Top of Page
   

- Advertisement -