Jump to content

Change date format for Data conversion

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 - '
    + datename(month,cast(format(transdate, 'yyyy-MM-01') as Date)) + ' ' +
    + CAST ( YEAR(cast(format(transdate, 'yyyy-MM-01') as Date)) as varchar)

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...