Summary: From this post you will learn how to use date and time conversion function. SQL Server provides a number of options you can use to format a date/time string. How to get different SQL Server date formats: Use the date format option along with CONVERT function. To get YYYY-MM-DD use SELECT CONVERT(varchar, getdate(), 23). To get MM/DD/YYYY use SELECT CONVERT(varchar, getdate(), 1). Check out the chart to get a list of all format options. Convert datetime to date using the CONVERT() function This statement uses the CONVERT() function to convert a datetime to a date: Syntax: CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) expression - Any valid expression. data_type - The target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used. length - An optional integer that specifies the length of the target data type, for data types that allow a user specified length. The default value is 30. s...
SQL Server SQL Server is a relational database management system (RDBMS) developed by Microsoft. SQL Server supports a wide variety of transaction processing, business intelligence and analytics applications in corporate IT environments. SQL Server supports ANSI SQL, which is the standard SQL (Structured Query Language) language. However, SQL Server comes with its own implementation of the SQL language, T-SQL. Why SQL Server? Microsoft SQL Server is a comprehensive database server and information platform offering a complete set of enterprise-ready technologies and tools that help people derive the most value from information at the lowest total-cost-of-ownership. Enjoy high levels of performance, availability, and security; employ more productive management and development tools; and deliver pervasive insight with self-service business intelligence (BI). A complete and integrated platform, Microsoft SQL Server brings it all together to get more value out of existing IT skills and asse...