What have you declared @month, @day and @year as? VARCHAR or INT?

This works:

DECLARE @month VARCHAR(3), @day VARCHAR(2), @year VARCHAR(4)

SET @month = CONVERT(VARCHAR(3), DATENAME(m, GETDATE()))
SET @day = CONVERT(VARCHAR(2), DATEPART(d, GETDATE()))
SET @year = CONVERT(VARCHAR(4), DATEPART(yyyy, GETDATE()))

SELECT @month + '-' + @day + '-' + @year

Ade

-----Original Message-----
From: Eric Creese [mailto:[EMAIL PROTECTED]
Sent: 20 January 2005 22:05
To: CF-Talk
Subject: Using variables to build a string


I am trying to build a chatracter string with parts of a date to name an
excel file I am outputing. But it's trying to mathmatically calulate the
values. Can't remember how to do this. can anyone help???

SET @month = CONVERT(varchar(3),DATENAME(m,getdate()))
SET @day = CONVERT(varchar(2),DATEPART(d,getdate()))
SET @year = CONVERT(varchar(4),DATEPART(yyyy,getdate()))

SET @filenameend = @month+'-'[EMAIL PROTECTED]'-'[EMAIL PROTECTED]
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 21/01/2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware: a new and convenient web-based time tracking application. Start 
tracking and documenting hours spent on a project or with a client with Logware 
today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:191430
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to