Solved

convert datetime

Posted on 2006-07-07
4
1,119 Views
Last Modified: 2008-03-10
CONVERT(DATETIME, CONVERT(VARCHAR(10), GETDATE(),120), 120)

I am using the above to only get the date and exclude the time.  

I get Jul  7 200

Is there a way that I can get 07/07/2006 instead?

I got this convertion from another question that I asked and just cut and paste, but can anyone walk me through with what its doing?  

thanks!!
0
Comment
Question by:yanci1179
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Accepted Solution

by:
william007 earned 300 total points
ID: 17059732
Try this
select CONVERT(VARCHAR(10), GETDATE(),101)
It convert the date the varchar in mm/dd/yyyy format.
0
 
LVL 10

Assisted Solution

by:ibost
ibost earned 100 total points
ID: 17059740
if you just want to drop the time portion of the date and then return a datetime datatype, you could use this:

cast(datediff(day, 0, getdate()) as datetime)
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 100 total points
ID: 17059761
Hi yanci1179,

ALSO

select CONVERT(VARCHAR(10), GETDATE(),101)  -- mm/dd/yyyy
select CONVERT(VARCHAR(10), GETDATE(),103) --dd/mm/yyyy


refer BOOKS online for 'Convert'

Aneesh R!
0
 

Author Comment

by:yanci1179
ID: 17059808
thanks
0

Featured Post

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question