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
Best Way to Test a Python Script?
What is a STMP
how do you change the registry so all user profiles are located on a seperate partition
#5.7.1 smtp;550 5.7.1 Unable to relay
i386 file
Mysql server failed to start on redhat AS4
Error when installing Mongrel Gem - ERROR: Failed to build gem native extension.
IAS 2003 Radius connect problem
!! Start Up Folder Problem !!
Unable to receive emails from outside network