dbTalk Databases Forums  

DTS date function

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


Discuss DTS date function in the microsoft.public.sqlserver.dts forum.



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

Default DTS date function - 01-21-2005 , 10:09 AM






I have to export date data to a text file for use on a UNIX server. The
programmer is asking for the date field to be split up into two fields.

YYYYMMDD and
HHMMSS

If I convert the datetime filed to a string using eithier of the MONTH, DAY,
YEAR or DATEPART function it drops the fill zero on numbers less than 10.

Does a function exist that will not drop the fill zero on months, days or
time segments less than 10?


Reply With Quote
  #2  
Old   
Francesco Anti
 
Posts: n/a

Default Re: DTS date function - 01-21-2005 , 10:29 AM






MONTH, DAY, YEAR and DATEPART return an integer value, that doesn't have
leading zeros.
Try to convert this value into a string ...
something like this: "right('0' + convert(char(2), month(DateField)) ,2)"
should function.
Then you can concatenate the values and eventually convert all into a
numeric value, if necessary.

Francesco Anti


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

Quote:
I have to export date data to a text file for use on a UNIX server. The
programmer is asking for the date field to be split up into two fields.

YYYYMMDD and
HHMMSS

If I convert the datetime filed to a string using eithier of the MONTH,
DAY,
YEAR or DATEPART function it drops the fill zero on numbers less than 10.

Does a function exist that will not drop the fill zero on months, days or
time segments less than 10?




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

Default Re: DTS date function - 01-21-2005 , 10:47 AM



Add an RTRIM before the RIGHT and it's perfect!

Thanks Francesco.

"Francesco Anti" wrote:

Quote:
MONTH, DAY, YEAR and DATEPART return an integer value, that doesn't have
leading zeros.
Try to convert this value into a string ...
something like this: "right('0' + convert(char(2), month(DateField)) ,2)"
should function.
Then you can concatenate the values and eventually convert all into a
numeric value, if necessary.

Francesco Anti


"Gary" <Gary (AT) discussions (DOT) microsoft.com> wrote in message
news:266B9133-024E-46E5-AAE4-5D7A55C15026 (AT) microsoft (DOT) com...
I have to export date data to a text file for use on a UNIX server. The
programmer is asking for the date field to be split up into two fields.

YYYYMMDD and
HHMMSS

If I convert the datetime filed to a string using eithier of the MONTH,
DAY,
YEAR or DATEPART function it drops the fill zero on numbers less than 10.

Does a function exist that will not drop the fill zero on months, days or
time segments less than 10?





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 - 2013, Jelsoft Enterprises Ltd.