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 2000 Forums
 Transact-SQL (2000)
 Seemingly simple date question

Author  Topic 

lauramayer
Posting Yak Master

152 Posts

Posted - 2006-01-12 : 12:09:12
Afternoon,

I'm sure this is simple I just cant seem to get the format right. I need it to look like: 01-13 what I get is Jan 13


select left(DATEADD(day, 1, convert(varchar,getdate(),110)),6)


Any help would be appreciated.

Thanks

Laura

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-01-12 : 12:23:09
First, formatting should be done by the interface, not the server!

Second, you are converting the date to varchar(), and then converting it back to datetime when you send it as a parameter to DATEADD(), and then converting it back to string when you send it as a parameter to LEFT().

Try this:
select CONVERT(char(5), DATEADD(day, 1, getdate()), 110)

You may need to use a different format than 110, but I don't have the options in front of me right now...
Go to Top of Page

lauramayer
Posting Yak Master

152 Posts

Posted - 2006-01-12 : 13:04:47
perfect thanks.
Go to Top of Page
   

- Advertisement -