Solved

convert datetime

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

912 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

17 Experts available now in Live!

Get 1:1 Help Now