Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Help!!!!

Status
Not open for further replies.

klmc

Programmer
Nov 14, 2003
18
US
I am creating a DTS package to import a .txt file that is pipe delimited. I am bringing it into a SQL2K db. My problem is that in the file, the date is listed as dd/mm/yyyy hh:mm:ss. I need to only bring over the dd/mm/yyy part. I know that there has to be a way to do this in the transformations.

Currently, my code is:
Code:
Function Main()
If DTSSource("COL001") = "1" Then
Main = DTSTransformStat_OK
Else
Main = DTSTransformStat_SkipRow
End If
End Function

The order of the columns in the file matches the order of the columns in the table.

Here is also a line of the file so that it may clarify what I am asking.
1|GIFT CARD|672698000003|800000880826|CAMP BOWIE # 3|Activation/Issuance (New)|1|11/25/2003 12:16:25PM|6035710008090252507|729184|5|3|10

Thanks in advance for any help!!!
 
IF there is a space between the date and time, could use ActiveX script (VB), using instr to locate the space. Alternatively could use RTrim to trim off the time.
=

Sometimes the grass is greener on the other side because there is more manure there - original.
 
There is a space between them so I'm guessing that the instr will work. I'm still not very familiar with ActiveX Script in a DTS package, (or VB for that matter.) Could you give me an example of the instr? I would really appreciate it. Thanks.
 
Here is a function that returns a date only from a date/time field.

CREATE FUNCTION justdate (@dttm DATETIME)
RETURNS nvarchar(10)
AS


BEGIN
DECLARE @udfddmmyyyy nvarchar(10)
SELECT @udfddmmyyyy = RIGHT('0' + CAST(Day(@dttm) AS
Varchar(2)), 2) + '/' + RIGHT('0' + CAST(Month(@dttm) AS
Varchar(2)), 2) + '/' + CAST(Year(@dttm) AS Varchar(4))
RETURN(@udfddmmyyyy)
END

--Example
--SELECT dbo.justdate(getdate())
-- move the date parts around in the SELECT to order them as you like
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top