Jump to content

Change date format for Data conversion


Megpiri

Recommended Posts

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

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...