mohamed-mhiri
mohamed-mhiri

Reputation: 232

Retrieve only date from datetime

I am using a derived column with ssis with this condition :

UpdatedDate == (DT_DATE)"9999-12-31" ? (DT_DATE)CreatedDate : (DT_DATE)UpdatedDate

This is my actual output, I'm storing the result in BI_StartDate :

EmployeeId createdDate updatedDate BI_StartDate
54         2013-07-10  9999-12-31  2013-07-10 00:00:00.0000000
245        2016-06-29  2016-07-03  2016-07-03 00:00:00.0000000

I want to get only the date:

EmployeeId createdDate updatedDate BI_StartDate
54         2013-07-10  9999-12-31  2013-07-10
245        2016-06-29  2016-07-03  2016-07-03

Upvotes: 1

Views: 47

Answers (2)

KumarHarsh
KumarHarsh

Reputation: 5094

Alternatively (for Knowledge Sake),

Use DT_DBDATE instrad of DT_DATE

UpdatedDate == (DT_DBDATE)"9999-12-31" ? (DT_DBDATE)CreatedDate : (DT_DBDATE)UpdatedDate

Upvotes: 2

Doliprane
Doliprane

Reputation: 151

You only need to cast / convert it to date data type by using:

CAST(BI_StartDate AS DATE)

or :

CONVERT(DATE, BI_StartDate)

Upvotes: 3

Related Questions