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

obtaining tme a file was created 1

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
0
0
DE
Hello

I am using SQL 2000

I could do this in vbscript but just wonder if it is possible in SQL
I want to populate a file with the time that a file was created (not a table, a text file)
How do I get that time and date using SQL?

Thanks

Damian
 
You can use

select getdate()

which will give --> 2003-09-03 11:12:16.733
 
DECLARE @FilePath varchar(250)
DECLARE @FileName varchar(250)
DECLARE @Year varchar(4)
DECLARE @FileDate varchar(10)

SET @FilePath = 'c:\FilePath\'
SET @FileName = 'FileName.Ext'

SET @Cmd = 'dir ' + @FilePath + @FileName
INSERT INTO #FileDate EXEC master.dbo.xp_cmdshell @Cmd

SELECT @Year = RIGHT(LEFT(field1 ,10),4) from #FileDate WHERE field1 like '%FileName.Ext%'

SELECT @FileDate = LEFT(field1 ,10) from #FileDate WHERE field1 like '%FileName.Ext%'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top