Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to convert datetime to string format (YYYYMMDD) in SSIS? Expand / Collapse
Author
Message
Posted Wednesday, February 27, 2013 10:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, April 26, 2013 1:47 AM
Points: 3, Visits: 62
How to convert datetime to string format (YYYYMMDD) in SSIS?

I have done using Datepart but for the date 01 to 09 it gives the values as 1 to 9. I need values should be as 01. Anybody guide me
Post #1424899
Posted Wednesday, February 27, 2013 10:48 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 3:46 PM
Points: 23,396, Visits: 32,227
Not sure how to do it in SSIS but in T-SQL:

CONVERT(VARCHAR(8),MyDateCol, 112)

Can you convert it prior to SSIS doing its thing?



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1424908
Posted Thursday, February 28, 2013 1:13 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:23 AM
Points: 5,074, Visits: 11,852
karthick.alangattan (2/27/2013)
How to convert datetime to string format (YYYYMMDD) in SSIS?

I have done using Datepart but for the date 01 to 09 it gives the values as 1 to 9. I need values should be as 01. Anybody guide me


You can get round the issue you mentioned by doing something like this (untested):

right("0" + Datepart(...), 2)




Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1424940
Posted Thursday, February 28, 2013 9:14 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, September 11, 2014 11:57 AM
Points: 504, Visits: 1,869
Here's another option.

REPLACE((DT_WSTR, 10)(DT_DBDATE)GETDATE(),"-","")

Post #1425098
Posted Thursday, February 28, 2013 10:10 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:23 AM
Points: 5,074, Visits: 11,852
kl25 (2/28/2013)
Here's another option.

REPLACE((DT_WSTR, 10)(DT_DBDATE)GETDATE(),"-","")



Good stuff - this is the way to go.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1425165
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse