dbTalk Databases Forums  

Re: format number

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Re: format number in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: format number - 09-13-2004 , 02:06 PM






SELECT RIGHT('0' + CAST(DATEPART(m,GETDATE()) AS VARCHAR(2)),2)

--
Andrew J. Kelly SQL MVP


"Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote

Quote:
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



Reply With Quote
  #2  
Old   
Ed
 
Posts: n/a

Default Re: format number - 09-13-2004 , 02:27 PM






Andrew,
Thanks for your answer.
but i am doing it in DTS ActiveXScript!!!
Edmund


"Andrew J. Kelly" wrote:

Quote:
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




Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: format number - 09-13-2004 , 02:49 PM



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

Quote:
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






Reply With Quote
  #4  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: format number - 09-13-2004 , 05:26 PM



Thanks Allan<g>

--
Andrew J. Kelly SQL MVP


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
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








Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.