Avatar of MrDavidThorn
MrDavidThorn

asked on 

Get just date from TSQL get date

Hi Experts

I have a datetime field in SQL and i want to inesrt the current date but not the time so the format would be 2011/10/09 00:00:00

Is there a function I can use for this or do I use string manipulation on getdate()?
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Patrick Matthews
Avatar of Eyal
Eyal
Flag of Israel image

select cast(cast(GETDATE() as date) as datetime)
Avatar of MrDavidThorn
MrDavidThorn

ASKER

Sorry Im using SQL 2005 so dont have date has a data type
ASKER CERTIFIED SOLUTION
Avatar of MrDavidThorn
MrDavidThorn

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of MrDavidThorn
MrDavidThorn

ASKER

should have googled at bit more
Avatar of Eyal
Eyal
Flag of Israel image

SELECT LEFT(CONVERT(VARCHAR, GETDATE(), 120), 10)
Avatar of Patrick Matthews
Eyal,

The date data type did not debut until SQL 2008.

Patrick
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo