Solved

convert datetime

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now