Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datetime

Status
Not open for further replies.

sardinka2

Programmer
May 6, 2004
38
US
From I query I have a data returning back as:
9/1/2004 12:00:00 AM
I would like to get only date without time.what function should I use.
 
You can use the CONVERT function to change the datetype to varchar, then apply the style of your choice.

Code:
SELECT CONVERT(varchar, MyDateField, 101)
  FROM MyTable
This example of the 101 syle returns mm/dd/yyyy format.

HTH,
John
 
hi
you can use the left function to pull back the number of characters from the left that you need or use the convert function to pull back the date

left("field name", (number of characters)
convert(varchar (10), "field name", style)

style 101 returns the date as mm/dd/yyyy

jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top