Megpiri Posted February 26, 2019 Share Posted February 26, 2019 I'm trying to change the date format in the below query to MM-01-yyyy but when I change it throws up an error. HELP! - Thanks cast(format(transdate, 'yyyy-MM-01') as Date) as 'Start Date', eomonth(cast(format(transdate, 'yyyy-MM-01') as Date)) as 'End Date', 'Mobile (ex)'as 'Type of Expense', CASE left(general2,8) WHEN 'Outgoing' THEN 'Mobile Phone Charges - ' WHEN 'Incoming' THEN 'Mobile Phone Charges - ' WHEN 'Parking ' THEN 'Parking Charges - ' WHEN 'Landline' THEN 'Landline Phone Charges - ' ELSE 'DATA - ' END + datename(month,cast(format(transdate, 'yyyy-MM-01') as Date)) + ' ' + + CAST ( YEAR(cast(format(transdate, 'yyyy-MM-01') as Date)) as varchar) Link to comment Share on other sites More sharing options...
Makwana Prahlad Posted March 3, 2020 Share Posted March 3, 2020 Hello, @Megpiri Please try this query,To Change date format for Data conversion: select convert(varchar,getdate(),107) as "Date" I hope above query will be useful for you. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now