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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with datepart function. 1

Status
Not open for further replies.

bsimbeck

Programmer
May 2, 2003
44
US
When using use the datepart function to return a the minutes of a time if the time is 9:06 then I only get 6 when I do datepart(mi, act_dt). Does anyone know how I can get it to produce the leading zero?

Note: act_dt is the field name of the field that contains the datetime. I have tried casting it as int, a varchar, and a decimal none have worked.

Thanks in Advance!

Branden
 
Code:
SELECT RIGHT('0' + CAST(DATEPART(mi, act_dt) AS varchar), 2)
FROM tbl

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top