Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Take a piece of a Date Field

Author  Topic 

sross81
Posting Yak Master

228 Posts

Posted - 2011-04-18 : 23:04:00
I have a field called Start_Date that is datetime datatype. I want only return the mmddyy. How would I do this?

Thanks in Advance!
Sherri

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-04-18 : 23:06:08
this is just a presentation issue. Can you do it in your frond end application ?

if you really want to do it in T-SQL, check out cast & convert in Books OnLine


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sross81
Posting Yak Master

228 Posts

Posted - 2011-04-18 : 23:08:31
It is not for display on the front end. I need to use the value to create a concatenated list of values that will be passed to another application.

I have been looking at cast and convert. I'm having bad luck so far. I never can get it to just mmddyy.

Thanks for the idea :)

quote:
Originally posted by khtan

this is just a presentation issue. Can you do it in your frond end application ?

if you really want to do it in T-SQL, check out cast & convert in Books OnLine


KH
[spoiler]Time is always against us[/spoiler]





Thanks in Advance!
Sherri
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-04-18 : 23:15:21
[code]
select stuff(replace(convert(varchar(10), getdate(), 101), '/', ''), 5, 2, '')
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-04-19 : 03:56:40
SQL Server: 20 Most Commonly Used DateTime Formats
http://connectsql.blogspot.com/2011/02/sql-server-20-most-commonly-used.html

Go to Top of Page

ricky_1605
Starting Member

30 Posts

Posted - 2011-04-19 : 05:31:49
Convert(Varchar(10), Start_Date, 101)

Nipun Chawla
Go to Top of Page
   

- Advertisement -