Microsoft
Software
Hardware
Network
Question : CAST(MONTH(DDate) AS VarChar(20)) need two digits not one.
I am using the following SQL to return the month number.
CAST(MONTH(DDate) AS VarChar(20)) as MonthNumber
The results are a single digit. For example, 2 instead of 02.
How can I put in a leading zero where needed and miss it out on months which are already two digits long?
Answer : CAST(MONTH(DDate) AS VarChar(20)) need two digits not one.
try
select
Case When Len(CAST(MONTH(DDate) AS VarChar(20))) = 1
then '0' + CAST(MONTH(DDate) AS VarChar(20))
Else CAST(MONTH(DDate) AS VarChar(20)) End
as MonthNumber
Random Solutions
Internet Explorer 7 stopped working on an XP pro desktop machine
Sort by Seconds, Milliseconds
Performance Issues with SQL Reporting Services 2008
Is there a way to find out all keywords ranked on Google for your site?
"The network connection to your application was interrupted"
microsoft outlook 2007 - disable reading pane
Applications missing under Iseries Navigator
Cant get rid of EFS0.tmp file.
Powershell foreach-object, supply values for the following parameters
exec(<string>) & cursor in SQL6.5