Solved

SSIS Derive column for converting  bigint datetimekey

Posted on 2013-06-11
7
1,365 Views
Last Modified: 2016-02-11
Hi,

I have a issue converting Datetime field to integer using derive column.
it could be a limitation on derive column.

my Derive column expression as follows:

YEAR(ValidLastAlertDate) * 100000000 + (MONTH(ValidLastAlertDate) * 1000000) + DAY(ValidLastAlertDate) * 10000 + DATEPART("hh",ValidLastAlertDate) * 100 + DATEPART("mi",ValidLastAlertDate)


Data Types:

four-byte signed integer [DT_I4]                                                

Can anybody has the solution to this?

Thanks in advance
0
Comment
Question by:keplan
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39239974
0
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39239985
Here is another way..

select ValidLastAlertDate
,(CONVERT(BIGINT,YEAR(ValidLastAlertDate)) * 100000000)+(CONVERT(BIGINT,MONTH(ValidLastAlertDate)) * 1000000)+(CONVERT(BIGINT,DAY(ValidLastAlertDate)) * 10000)+DATEPART("hh",ValidLastAlertDate) * 100+DATEPART("mi",ValidLastAlertDate)
 from YOUR_TABLE (nolock) where [id]=1

Open in new window


HTH,

Kent
0
 

Author Comment

by:keplan
ID: 39240803
Hi HTH,

I need this to be achieved through SSIS.
So Is this a limitation on SSIS
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 21

Expert Comment

by:Jason Yousef, MS
ID: 39240831
Hi,
what's the expected output (result) ?  not data type...
0
 

Author Comment

by:keplan
ID: 39243017
Out come is the DateTimeKey as interger value:

Eg:

201305301230
0
 
LVL 21

Accepted Solution

by:
Jason Yousef, MS earned 370 total points
ID: 39248340
[DT_I4]   is INT and that's small for your expected output...
cast to BIG int instead [DT_I8]
(DT_I8)YEAR(ValidLastAlertDate) * 100000000 + (MONTH(ValidLastAlertDate) * 1000000) + DAY(ValidLastAlertDate) * 10000 + DATEPART("hh",ValidLastAlertDate) * 100 + DATEPART("mi",ValidLastAlertDate)

Open in new window


Please let me know if you got an error and what's the error.
0
 

Author Closing Comment

by:keplan
ID: 39249499
Good
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now