storing datetime2 in ssis variable
I'm using SQL Server 2012 Enterprise
. I have a requirement where I've to store data with DATETIME2
datatype in SSIS Variable. Unfortunately, SSIS variables don't have that data type.
If I'm storing it into datetime
data type, I'm losing information. Can anyone help in giving workaround?
PS: My source system is SQL Server 2012 as well and I'm reading the data from column with datetime2 datatype.
sql-server datetime ssis
|
show 4 more comments
I'm using SQL Server 2012 Enterprise
. I have a requirement where I've to store data with DATETIME2
datatype in SSIS Variable. Unfortunately, SSIS variables don't have that data type.
If I'm storing it into datetime
data type, I'm losing information. Can anyone help in giving workaround?
PS: My source system is SQL Server 2012 as well and I'm reading the data from column with datetime2 datatype.
sql-server datetime ssis
I dont know aboutSSIS variables
... can you try that, store thedatetime2
asvarchar
orstring
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.
– IdontKnowEnglish
Dec 28 '18 at 8:08
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
1
Looks likeDT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…
– Peter B
Dec 28 '18 at 8:19
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you wantDT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option ofdatetime
. The documentation doesn't state what value types are available, however, theDateTime
datatype is equivilent to adatetime2(0)
.
– Larnu
Dec 28 '18 at 9:05
1
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store2018-12-28 09:06:34.123456
as20181229090634.123456
or maybe599303194123456000
(number of nanoseconds between2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.
– Larnu
Dec 28 '18 at 9:05
|
show 4 more comments
I'm using SQL Server 2012 Enterprise
. I have a requirement where I've to store data with DATETIME2
datatype in SSIS Variable. Unfortunately, SSIS variables don't have that data type.
If I'm storing it into datetime
data type, I'm losing information. Can anyone help in giving workaround?
PS: My source system is SQL Server 2012 as well and I'm reading the data from column with datetime2 datatype.
sql-server datetime ssis
I'm using SQL Server 2012 Enterprise
. I have a requirement where I've to store data with DATETIME2
datatype in SSIS Variable. Unfortunately, SSIS variables don't have that data type.
If I'm storing it into datetime
data type, I'm losing information. Can anyone help in giving workaround?
PS: My source system is SQL Server 2012 as well and I'm reading the data from column with datetime2 datatype.
sql-server datetime ssis
sql-server datetime ssis
asked Dec 28 '18 at 7:57
Prabhat GPrabhat G
2,47611324
2,47611324
I dont know aboutSSIS variables
... can you try that, store thedatetime2
asvarchar
orstring
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.
– IdontKnowEnglish
Dec 28 '18 at 8:08
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
1
Looks likeDT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…
– Peter B
Dec 28 '18 at 8:19
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you wantDT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option ofdatetime
. The documentation doesn't state what value types are available, however, theDateTime
datatype is equivilent to adatetime2(0)
.
– Larnu
Dec 28 '18 at 9:05
1
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store2018-12-28 09:06:34.123456
as20181229090634.123456
or maybe599303194123456000
(number of nanoseconds between2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.
– Larnu
Dec 28 '18 at 9:05
|
show 4 more comments
I dont know aboutSSIS variables
... can you try that, store thedatetime2
asvarchar
orstring
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.
– IdontKnowEnglish
Dec 28 '18 at 8:08
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
1
Looks likeDT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…
– Peter B
Dec 28 '18 at 8:19
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you wantDT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option ofdatetime
. The documentation doesn't state what value types are available, however, theDateTime
datatype is equivilent to adatetime2(0)
.
– Larnu
Dec 28 '18 at 9:05
1
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store2018-12-28 09:06:34.123456
as20181229090634.123456
or maybe599303194123456000
(number of nanoseconds between2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.
– Larnu
Dec 28 '18 at 9:05
I dont know about
SSIS variables
... can you try that, store the datetime2
as varchar
or string
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.– IdontKnowEnglish
Dec 28 '18 at 8:08
I dont know about
SSIS variables
... can you try that, store the datetime2
as varchar
or string
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.– IdontKnowEnglish
Dec 28 '18 at 8:08
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
1
1
Looks like
DT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…– Peter B
Dec 28 '18 at 8:19
Looks like
DT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…– Peter B
Dec 28 '18 at 8:19
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you want
DT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option of datetime
. The documentation doesn't state what value types are available, however, the DateTime
datatype is equivilent to a datetime2(0)
.– Larnu
Dec 28 '18 at 9:05
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you want
DT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option of datetime
. The documentation doesn't state what value types are available, however, the DateTime
datatype is equivilent to a datetime2(0)
.– Larnu
Dec 28 '18 at 9:05
1
1
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store
2018-12-28 09:06:34.123456
as 20181229090634.123456
or maybe 599303194123456000
(number of nanoseconds between 2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.– Larnu
Dec 28 '18 at 9:05
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store
2018-12-28 09:06:34.123456
as 20181229090634.123456
or maybe 599303194123456000
(number of nanoseconds between 2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.– Larnu
Dec 28 '18 at 9:05
|
show 4 more comments
1 Answer
1
active
oldest
votes
SSIS, at least currently, has a "known" shortfall in that the variable value type, DateTime
only has a precision to the second; effectively the same as a datetime2(0)
. If you therefore need to store anything more accurate that a second, such as if you are using datetime
and the 1/300 of a second is important or if you are using datetime2
with a precision of 1 or more, the value type DateTime
, will not serve your goal.
A couple of different options are therefore to store the value of as a String
or numerical value. This does, however, come with it's own problems; most and foremost that neither of these datatypes are date and time datatypes.
It therefore depends what your goal is. I would most likely make use of a String
datatype and ensure it has the ISO format ('yyyy-MM-ddThh:mm:ss.nnnnnnn'
). If you're then using something like a T-SQL Task you can pass your variable as normal to the task and the data engine will interpret the literal string as a datetime2(7)
(or whichever literal precision you used).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955344%2fstoring-datetime2-in-ssis-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
SSIS, at least currently, has a "known" shortfall in that the variable value type, DateTime
only has a precision to the second; effectively the same as a datetime2(0)
. If you therefore need to store anything more accurate that a second, such as if you are using datetime
and the 1/300 of a second is important or if you are using datetime2
with a precision of 1 or more, the value type DateTime
, will not serve your goal.
A couple of different options are therefore to store the value of as a String
or numerical value. This does, however, come with it's own problems; most and foremost that neither of these datatypes are date and time datatypes.
It therefore depends what your goal is. I would most likely make use of a String
datatype and ensure it has the ISO format ('yyyy-MM-ddThh:mm:ss.nnnnnnn'
). If you're then using something like a T-SQL Task you can pass your variable as normal to the task and the data engine will interpret the literal string as a datetime2(7)
(or whichever literal precision you used).
add a comment |
SSIS, at least currently, has a "known" shortfall in that the variable value type, DateTime
only has a precision to the second; effectively the same as a datetime2(0)
. If you therefore need to store anything more accurate that a second, such as if you are using datetime
and the 1/300 of a second is important or if you are using datetime2
with a precision of 1 or more, the value type DateTime
, will not serve your goal.
A couple of different options are therefore to store the value of as a String
or numerical value. This does, however, come with it's own problems; most and foremost that neither of these datatypes are date and time datatypes.
It therefore depends what your goal is. I would most likely make use of a String
datatype and ensure it has the ISO format ('yyyy-MM-ddThh:mm:ss.nnnnnnn'
). If you're then using something like a T-SQL Task you can pass your variable as normal to the task and the data engine will interpret the literal string as a datetime2(7)
(or whichever literal precision you used).
add a comment |
SSIS, at least currently, has a "known" shortfall in that the variable value type, DateTime
only has a precision to the second; effectively the same as a datetime2(0)
. If you therefore need to store anything more accurate that a second, such as if you are using datetime
and the 1/300 of a second is important or if you are using datetime2
with a precision of 1 or more, the value type DateTime
, will not serve your goal.
A couple of different options are therefore to store the value of as a String
or numerical value. This does, however, come with it's own problems; most and foremost that neither of these datatypes are date and time datatypes.
It therefore depends what your goal is. I would most likely make use of a String
datatype and ensure it has the ISO format ('yyyy-MM-ddThh:mm:ss.nnnnnnn'
). If you're then using something like a T-SQL Task you can pass your variable as normal to the task and the data engine will interpret the literal string as a datetime2(7)
(or whichever literal precision you used).
SSIS, at least currently, has a "known" shortfall in that the variable value type, DateTime
only has a precision to the second; effectively the same as a datetime2(0)
. If you therefore need to store anything more accurate that a second, such as if you are using datetime
and the 1/300 of a second is important or if you are using datetime2
with a precision of 1 or more, the value type DateTime
, will not serve your goal.
A couple of different options are therefore to store the value of as a String
or numerical value. This does, however, come with it's own problems; most and foremost that neither of these datatypes are date and time datatypes.
It therefore depends what your goal is. I would most likely make use of a String
datatype and ensure it has the ISO format ('yyyy-MM-ddThh:mm:ss.nnnnnnn'
). If you're then using something like a T-SQL Task you can pass your variable as normal to the task and the data engine will interpret the literal string as a datetime2(7)
(or whichever literal precision you used).
answered Dec 28 '18 at 9:36
LarnuLarnu
16.1k41630
16.1k41630
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955344%2fstoring-datetime2-in-ssis-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I dont know about
SSIS variables
... can you try that, store thedatetime2
asvarchar
orstring
in SSIS.? If did, then you can convert varchar to datetime2 in SQL Server.– IdontKnowEnglish
Dec 28 '18 at 8:08
what are you losing exactly? It is DateTime format from (.Net Framework)
– Simonare
Dec 28 '18 at 8:14
1
Looks like
DT_DBTIMESTAMP2
should work: docs.microsoft.com/en-us/sql/integration-services/data-flow/…– Peter B
Dec 28 '18 at 8:19
Depends what you mean by "store". When in a dataflow task, then @PeterB is correct, you want
DT_DBTIMESTAMP2
. If you're declaring a variable, however, then you only have the option ofdatetime
. The documentation doesn't state what value types are available, however, theDateTime
datatype is equivilent to adatetime2(0)
.– Larnu
Dec 28 '18 at 9:05
1
If you need a higher scale you are (unfortunately) forced to use the string datatype, or convert your datetime is an numerical and work with that. For example, maybe you'll store
2018-12-28 09:06:34.123456
as20181229090634.123456
or maybe599303194123456000
(number of nanoseconds between2000-01-01
and the date). It is a known "shortfall" of SSIS when working with its variables.– Larnu
Dec 28 '18 at 9:05