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

Expression --need 2 digit not 4 Expand / Collapse
Author
Message
Posted Thursday, January 24, 2008 3:01 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 2:01 PM
Points: 16, Visits: 477
I am trying to create an expression in ssis as follows:
"capp"+(DT_STR,4,1252) DatePart("yy",getdate()) +
Right("0" + (DT_STR,2,1252) DatePart("m",getdate()),2) +
Right("0" + (DT_STR,2,1252) DatePart("d",getdate()),2) + ".txt"

Displays
capp20080124.txt

What I want is capp080124.txt and I not sure how to get the year to be two digits and not four? Please help..
Post #447214
Posted Friday, November 15, 2013 2:44 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, December 9, 2013 7:49 AM
Points: 1, Visits: 23
Replace

(DT_STR,4,1252) DatePart("yy",getdate())

with

Right((DT_STR, 4, 1252)DatePart("yyyy", getdate()), 2)

This will return the last two (Right) digits of the year (ignoring the "20" century).
Post #1514868
Posted Monday, November 18, 2013 5:11 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
alane 46264 (11/15/2013)
Replace

(DT_STR,4,1252) DatePart("yy",getdate())

with

Right((DT_STR, 4, 1252)DatePart("yyyy", getdate()), 2)

This will return the last two (Right) digits of the year (ignoring the "20" century).


You just answered a five-year-old post - hope that they were not sitting there waiting!



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.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1515184
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse