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)
 datepart with minutes

Author  Topic 

SQL_Rookie
Starting Member

32 Posts

Posted - 2008-09-22 : 15:04:44
is there away to get minutes out of the datetime but need to have 2 digit minutes...seems like when the time is less the 10 minutes like 12:03:00 it only returns 3 not 03

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-22 : 15:21:04
datepart returns INT. Try this:
select right('0' + datename(minute, getdate()),2)

or do your formatting in your presentation layer.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -