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

SQL Date Question

Status
Not open for further replies.

Wallie12

MIS
Mar 5, 2004
92
US
I have the following in SQL Server 2008
Parm Input is Start as datetime

If I hard code a Date it works:
UPDATE [WORKING_SVR_CLOSED]
SET [TTRHours] = 'Yes'
FROM [GM].[dbo].[DATA_CLEANING] AS dc
LEFT OUTER JOIN [GM].[dbo].[WORKING_SVR_CLOSED] AS o ON DC.Number = o.DimensionDataRef
WHERE DC.[Date ] = CONVERT (CHAR(255),'04/14/10',107)

This Does not work:
UPDATE [WORKING_SVR_CLOSED]
SET [TTRHours] = 'Yes'
FROM [GM].[dbo].[DATA_CLEANING] AS dc
LEFT OUTER JOIN [GM].[dbo].[WORKING_SVR_CLOSED] AS o ON DC.Number = o.DimensionDataRef
WHERE DC.[Date ] = CONVERT (CHAR(255),@StartDate,107)

@StartDate comes out 2014/04/14

How can I correct this? Thanks in advance!
 
I do not know if it makes a difference but have you tried VARCHAR instead of CHAR? Do you really need 255 characters as I believe trailing spaces are ignored?

If you look at @StartDate it will show 2014/04/14 as that is how SQL looks at dates. As markros asks is DC.[Date] a character column?



djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top