Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 A Date Format Question

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2011-06-21 : 18:50:10
hi experts,

The derived file name below is OK except that I want the time to not have the : char. So I want 20110621_174600.csv

\\pncllwapp\E$\RAMCO\OUT\FINTG\LAWSON\PMI\INV_20110621_17:46:00.csv

I used Convert(varchar(8), @curDate, 108) but that is giving me the : chars

Any ideas? Thanks, John

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-21 : 18:58:42
You can use the REPLACE function to remove the unwanted characters.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2011-06-22 : 09:51:12
Thanks, Tara. That worked sweetly.

Here is the final code:

Set @ReportPath = '\\pncllwapp\E$\RAMCO\OUT\FINTG\LAWSON\PMI\' + 'INV' + '_' + Convert(varchar(8), @curDate, 112) + '_' + Convert(varchar(8), @curDate, 108) + '.csv'

-- Remove : chars from timestamp
select replace( replace( @ReportPath, ':', ''), ',', '')

print @ReportPath shows:

\\pncllwapp\E$\RAMCO\OUT\FINTG\LAWSON\PMI\INV_20110622_084900.csv
Go to Top of Page
   

- Advertisement -