![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hi, is there any functions in ActiveX script that i could change an output from 9 to 09 becuase if i use msgbox datepart("M", date()) the reault is 9 but i want the result to be 09??? I know I could easily use If Else Statement to test the len of the variable and then add a string "0" in front. but i am wondering is there any functions build in to change the format???? Thanks Edmund |
#2
| |||
| |||
|
|
SELECT RIGHT('0' + CAST(DATEPART(m,GETDATE()) AS VARCHAR(2)),2) -- Andrew J. Kelly SQL MVP "Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote in message news:A6895AA5-7531-4955-9FDD-7717FCD5DEE6 (AT) microsoft (DOT) com... Hi, is there any functions in ActiveX script that i could change an output from 9 to 09 becuase if i use msgbox datepart("M", date()) the reault is 9 but i want the result to be 09??? I know I could easily use If Else Statement to test the len of the variable and then add a string "0" in front. but i am wondering is there any functions build in to change the format???? Thanks Edmund |
#3
| |||
| |||
|
|
Andrew, Thanks for your answer. but i am doing it in DTS ActiveXScript!!! Edmund "Andrew J. Kelly" wrote: SELECT RIGHT('0' + CAST(DATEPART(m,GETDATE()) AS VARCHAR(2)),2) -- Andrew J. Kelly SQL MVP "Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote in message news:A6895AA5-7531-4955-9FDD-7717FCD5DEE6 (AT) microsoft (DOT) com... Hi, is there any functions in ActiveX script that i could change an output from 9 to 09 becuase if i use msgbox datepart("M", date()) the reault is 9 but i want the result to be 09??? I know I could easily use If Else Statement to test the len of the variable and then add a string "0" in front. but i am wondering is there any functions build in to change the format???? Thanks Edmund |
#4
| |||
| |||
|
|
What Andrew is driving at is that doing this inside an AX Script transform operates on a Row*Row basis and on large resultsets will be slow. Doing it in the SourceSQLStatement in the syntax of your source provider will be on 99.9% of occasions faster. If your provider does not support any syntax (Flat File) then you need still do not need to do this using an AX Script transform. Personally I would import the file into a staging table and do it from there in TSQL or whatever is your provider's labguage. If you _MUST_ use an AX Script transform then the If..Then..Else is the way forward -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. www.konesans.com - Consultancy from the people who know "Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote in message news:2A29603E-8CED-4453-BE81-D15FBEECB730 (AT) microsoft (DOT) com... Andrew, Thanks for your answer. but i am doing it in DTS ActiveXScript!!! Edmund "Andrew J. Kelly" wrote: SELECT RIGHT('0' + CAST(DATEPART(m,GETDATE()) AS VARCHAR(2)),2) -- Andrew J. Kelly SQL MVP "Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote in message news:A6895AA5-7531-4955-9FDD-7717FCD5DEE6 (AT) microsoft (DOT) com... Hi, is there any functions in ActiveX script that i could change an output from 9 to 09 becuase if i use msgbox datepart("M", date()) the reault is 9 but i want the result to be 09??? I know I could easily use If Else Statement to test the len of the variable and then add a string "0" in front. but i am wondering is there any functions build in to change the format???? Thanks Edmund |
![]() |
| Thread Tools | |
| Display Modes | |
| |