Alesh
Alesh

Reputation: 341

MySql merge two date columns to one column by query

I have two date columns from and to i want to query like

SELECT cast(E.From as varchar(20)) + ' to ' + cast(E.To as varchar(20)) DateRange,  
       E.Reason, L.Title as LeaveType 
  FROM employeeleave E 
       LEFT JOIN listitems L ON E.LeaveTypeID = L.ListItemID

and make a new column daterange.

My query is not working.

How do i cast date values to varchar in mysql.

Upvotes: 0

Views: 386

Answers (1)

M Khalid Junaid
M Khalid Junaid

Reputation: 64496

I guess you need concat

SELECT concat(E.From,' to ',E.To) DateRange,
E.Reason,
L.Title as LeaveType 
from employeeleave E 
LEFT JOIN listitems L ON E.LeaveTypeID = L.ListItemID

Upvotes: 1

Related Questions