Solved

convert datetime

Posted on 2006-07-07
4
1,114 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

759 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