Hi
I want to display 30/11/2023 Date as Nov'23
Regards
Hi
I want to display 30/11/2023 Date as Nov'23
Regards
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 6, 2024, 3:14 AM EST
Hello Ramco,
You can use this one,
DECLARE @inputDate VARCHAR(10) = '30/11/2023' SELECT LEFT(DATENAME( MONTH, CONVERT(DATE, @inputDate, 103)), 3) + ''' ' + CONVERT(VARCHAR(4), DATEPART(YEAR, CONVERT(DATE, @inputDate, 103))) AS formatted_dateAmit MohantyRank #112 · 20K reputationPosted Feb 6, 2024, 12:33 AM EST
Try this
DECLARE @yourDateString VARCHAR(10) = '30/11/2023'; DECLARE @yourDate DATE = CONVERT(DATE, @yourDateString, 103); SELECT CONCAT(FORMAT(@yourDate, 'MMM'), '''', FORMAT(@yourDate, 'yy')) AS FormattedDate;Rafnas T PRank #280 · 8.8K reputationPosted Feb 5, 2024, 10:45 PM EST
Hi Ramco,
You can wright below select query to format you date
SELECT DATE_FORMAT('2023-11-30', '%b''%y') AS FormattedDate;
if this answers your query, please accept this answer.
Vishal JoshiRank #377 · 6.7K reputationPosted Feb 6, 2024, 12:00 AM EST
Hello Ramco,
Please try the below SQL Query code to get date format as a month and year (MMM'yy).
DECLARE @frDate DATETIME SET @frDate = GETDATE() select left(datename(month, @frDate), 3) + '''' + right(datename(year, @frDate), 2)Please make sure that input variable or column datatype should be DateTime.
Thanks
Vishal
Mohammad HussainRank #513 · 4.8K reputationPosted Feb 6, 2024, 12:37 AM EST
Hi Ramco,
Please try this,
DECLARE @Date1 DATE = '2023-11-30'; SELECT FORMAT(@Date1, 'MMM''yy') AS NewDate;Anandu G NathRank #681 · 3.5K reputationPosted Feb 6, 2024, 12:27 AM EST
ASp.NetHub
#Asp.NetHub
Check this channel for more Videos
https://youtube.com/@asp.netsimpletutorial3964?si=1SdUvvq2SuNiLVzA
Jithu ThomasRank #437 · 5.7K reputationPosted Feb 6, 2024, 3:33 AM EST
CREATE PROCEDURE FormatDate @inputDate NVARCHAR(10) AS BEGIN DECLARE @formattedDate NVARCHAR(6) -- Convert the input date to a datetime object DECLARE @date datetime = CONVERT(datetime, @inputDate, 103) -- Format the date as 'MMM' for abbreviated month and 'YY' for the last two digits of the year SET @formattedDate = FORMAT(@date, 'MMM''YY') -- Return the formatted date SELECT @formattedDate AS FormattedDate ENDyou can execute the code by the following code: -
EXEC FormatDate '30/11/2023';