dbTalk Databases Forums  

formatting dates

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


Discuss formatting dates in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chris
 
Posts: n/a

Default formatting dates - 02-09-2004 , 12:26 PM






sql2k sp3

Ive got a DTS package that creates a folder with the
current date on it and replaces the /'s with an empty
string. A small example;

Function Main()
dim folder
folder = replace(date,"/","")
msgbox folder
Main = DTSTaskExecResult_Success
End Function

However if run today the msgbox will come up as "292004".
I need for it to come back as "02092004" to fit in with
alot of other stuff. Is there a way this can be done?

TIA, Chris

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

Default Re: formatting dates - 02-09-2004 , 01:52 PM






There is a way

This works for me


msgbox REPLACE(CSTR(FormatDateTime( now() , 2 )),"/","")





--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


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

Quote:
sql2k sp3

Ive got a DTS package that creates a folder with the
current date on it and replaces the /'s with an empty
string. A small example;

Function Main()
dim folder
folder = replace(date,"/","")
msgbox folder
Main = DTSTaskExecResult_Success
End Function

However if run today the msgbox will come up as "292004".
I need for it to come back as "02092004" to fit in with
alot of other stuff. Is there a way this can be done?

TIA, Chris



Reply With Quote
  #3  
Old   
chris
 
Posts: n/a

Default Re: formatting dates - 02-09-2004 , 04:41 PM



This produces the results I already had.

Quote:
-----Original Message-----
There is a way

This works for me


msgbox REPLACE(CSTR(FormatDateTime( now() , 2 )),"/","")





--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"chris" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:d78901c3ef3a$2f259680$a601280a (AT) phx (DOT) gbl...
sql2k sp3

Ive got a DTS package that creates a folder with the
current date on it and replaces the /'s with an empty
string. A small example;

Function Main()
dim folder
folder = replace(date,"/","")
msgbox folder
Main = DTSTaskExecResult_Success
End Function

However if run today the msgbox will come up
as "292004".
I need for it to come back as "02092004" to fit in with
alot of other stuff. Is there a way this can be done?

TIA, Chris


.


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.