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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get rid of decimal seconds from datetime export

Status
Not open for further replies.

MrJRW

IS-IT--Management
Feb 6, 2002
47
US
Good Afternoon

As part of a SSIS package, I have a task that exports a table to a text file. One of the fields is a datetime data type.

When exported, the datatime data is being stored as "YYYY-MM-DD HH:MM:SS.SSSSSSSSS" That's correct; nine decimal seconds.

I need to import this text file into an Access database. The decimal seconds are causing an import error.

? What would be the "best" way to just have interger seconds; HH:MM:SS ?

Thanks
JRW
 
This uses the GetDate() function, but shows you how this works. Make sure this returns what you want it to, and if it does, then just implement this in your code by replacing the GetDate() function with your actual column name.

Code:
Select DateAdd(Millisecond, -1 * DatePart(Millisecond, GetDate()), GetDate())

You could also use the smalldatetime data type, but this would remove the seconds portion also, which I think you probably don't want. Ex:

[tt][blue]
Select Convert(SmallDateTime, GetDate())
[/blue][/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top