Here's a simple piece of code for creating a string in YYYYMMDDHHMMSS format, suitable for use as a filename:
REPLACE(REPLACE(REPLACE(CONVERT(char(19), GETDATE(), 120), ' ', ''), '-', ''), ':', '')
If you ran this at 1:23:05 PM on December 3, 2006, it would return "20061203132305".
Wednesday, April 18, 2007
Handy SQL Server Query: Date String For Filename
Posted by Thomas at 4/18/2007 09:27:00 PM
Labels: date time string format, query analyzer, sql server
Subscribe to:
Post Comments (Atom)
1 comment:
Many thanks,
Saved me a couple of hours!
Rickard, Sweden
Post a Comment