You must Sign In to post a response.
Category: .NET
#769528
Hi Chanti,
I am not sure at where you want this output, I have prepared a logic in SQL. You can convert the same into a function and use it
Let me know if you have any questions
Regards,
V.M. Damodharan
"Your talent will be worthless, when you have fear and tension."
I am not sure at where you want this output, I have prepared a logic in SQL. You can convert the same into a function and use it
DECLARE @InputDate NVARCHAR(50) = 'December-2017'
DECLARE @Index INT = CHARINDEX('-',@InputDate)
DECLARE @MonthName NVARCHAR(20)= UPPER(SUBSTRING(@InputDate,0,@Index))
DECLARE @YearDate NVARCHAR(20) = SUBSTRING(@InputDate,@Index + 1,(LEN(@InputDate) - @Index) + 1)
SELECT @YearDate+(CASE WHEN @MonthName = 'JANUARY' THEN '01'
WHEN @MonthName = 'FEBRUARY' THEN '02'
WHEN @MonthName = 'MARCH' THEN '03'
WHEN @MonthName = 'APRIL' THEN '04'
WHEN @MonthName = 'MAY' THEN '05'
WHEN @MonthName = 'JUNE' THEN '06'
WHEN @MonthName = 'JULY' THEN '07'
WHEN @MonthName = 'AUGUST' THEN '08'
WHEN @MonthName = 'SEPTEMBER' THEN '09'
WHEN @MonthName = 'OCTOBER' THEN '10'
WHEN @MonthName = 'NOVEMBER' THEN '11'
WHEN @MonthName = 'DECEMBER' THEN '12'
ELSE '' END)
Let me know if you have any questions
Regards,
V.M. Damodharan
"Your talent will be worthless, when you have fear and tension."
#769629
Hi Chanti,
I don't know where you want the output. So this is my answer in C#
string[] array = Convert.ToString("December-2017").Split('-');
Label1.Text = array[1] + DateTime.ParseExact(array[0].ToString().SubString(0,3), "MMM", System.Globalization.CultureInfo.InvariantCulture).Month.ToString("00");
Hope this will help you.
Regards,
Nirav Lalan
DNS Gold Member
"If you can dream it, you can do it."
I don't know where you want the output. So this is my answer in C#
string[] array = Convert.ToString("December-2017").Split('-');
Label1.Text = array[1] + DateTime.ParseExact(array[0].ToString().SubString(0,3), "MMM", System.Globalization.CultureInfo.InvariantCulture).Month.ToString("00");
Hope this will help you.
Regards,
Nirav Lalan
DNS Gold Member
"If you can dream it, you can do it."
#769653
Basically when we work with .net we used to format the date value using Format function. so , below is the straight code to convert actual date value to expected format
Format(CDate("December-2017"),"yyyyMM")
Hope this will work and get you the expected format of value.
Thanks!
B.Ramana Reddy
Format(CDate("December-2017"),"yyyyMM")
Hope this will work and get you the expected format of value.
Thanks!
B.Ramana Reddy
Return to Return to Discussion Forum