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
 BASIC DATA TYPES

Author  Topic 

sambrown180
Starting Member

38 Posts

Posted - 2008-11-26 : 04:57:09
I know this is very basic but for some reason SQL 2005 will not let me use data types "DATE" is there another type that can be used instead of DATETIME as I just want the date to be shown and need to run queries using this.

Thanks

raky
Aged Yak Warrior

767 Posts

Posted - 2008-11-26 : 05:08:41
Date datatype is available only in sqlserver 2008 and in Sqlserver 2005 we have to use datetime datatype
To display only date we can make time part to Zero

see the difference in displaying presentdate and time

select getdate(), dateadd(d,datediff(d,0,getdate()),0)
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-11-26 : 05:48:07
SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]
OR
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 111), '/', '-') AS [YYYY-MM-DD]

Try these statements to get only date part
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-26 : 05:50:09
SELECT CONVERT(CHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-11-26 : 08:12:28
Try these

SELECT {FN CURRENT_DATE()}
SELECT {FN CURRENT_TIME()}
SELECT {FN NOW()}
SELECT {FN EXTRACT(HOUR FROM GETDATE())}
SELECT {FN EXTRACT(MINUTE FROM GETDATE())}
SELECT {FN EXTRACT(SECOND FROM GETDATE())}
SELECT {FN EXTRACT(DAY FROM GETDATE())}
SELECT {FN EXTRACT(MONTH FROM GETDATE())}
SELECT {FN EXTRACT(YEAR FROM GETDATE())}
SELECT {FN DAYNAME(GETDATE())}
SELECT {FN MONTHNAME(GETDATE())}
SELECT {FN MONTH(GETDATE())}
SELECT {FN YEAR(GETDATE())}

====================================================
you realize you've made a mistake, take immediate steps to correct it.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-26 : 08:14:11
Why would you like to invoke ODBC calls?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-11-26 : 08:35:45

Hi Peter,

Dont know exactly, Is there any issue if we use the ODBC Functions.

Would you explian?

====================================================
you realize you've made a mistake, take immediate steps to correct it.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-26 : 08:58:45
quote:
The introduction of OLE DB doesn't mean that Microsoft is dropping ODBC. For the foreseeable future, Microsoft plans to support ODBC, as do other database and tool vendors. So what's wrong with ODBC? Nothing. ODBC is adequate for data access. My real-world experience confirms that if ODBC meets your needs and your clients' needs, you can forget (for now) about OLE DB and related technologies.

However, ODBC has become a mature, fully expressed technology, and Microsoft probably won't develop it further. ODBC is on a dead-end track with a few switches left before the end of the line. The last of these switches shunts your applications toward OLE DB. And you have to decide whether you've already passed the last switch.

So nothing is wrong, unsupported, or invalid about ODBC. You know about its performance, flexibility, and architecture. You know about the various development tools and the framework built on top of ODBC (e.g., RDO). To determine how close you are to the point of decision, analyze how well your information system's planned future enhancements match ODBC's capabilities. Keep in mind that in the next five years, ODBC will provide virtually the same operational capabilities as it does today. ODBC will continue to let you access SQL data that isn't integrated with other, nonrelational data types such as extensible markup language (XML) files, Microsoft Office documents, or email. If these elements are part of your company's data store, you need to consider OLE DB.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-11-26 : 23:32:22

So, If we use scalar functions in SQL SERVER as query , it depends upon the OLEDB available.

Thanks Peter,



====================================================
you realize you've made a mistake, take immediate steps to correct it.
Go to Top of Page
   

- Advertisement -