• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

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()?
0
MrDavidThorn
Asked:
MrDavidThorn
  • 3
  • 2
1 Solution
 
EyalCommented:
select cast(cast(GETDATE() as date) as datetime)
0
 
MrDavidThornAuthor Commented:
Sorry Im using SQL 2005 so dont have date has a data type
0
 
MrDavidThornAuthor Commented:
Iv found DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0), which does the job, thanks anyhow!
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
MrDavidThornAuthor Commented:
should have googled at bit more
0
 
EyalCommented:
SELECT LEFT(CONVERT(VARCHAR, GETDATE(), 120), 10)
0
 
Patrick MatthewsCommented:
Eyal,

The date data type did not debut until SQL 2008.

Patrick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now