I am not sure if I have put this in the correct section as am new to the forums... please move if not.
I am using SQL Server 2005.
My problem is dates within a text string... within a query. I have lots of separate queries used for pulling data from the SQL database to word templates etc.
My query is below but want I would like to know is why the dates outside of a text string will pull in "01 January 2012" in word and dates inside a text string need a format given otherwise they pull in "Jan 01 2012 12:00AM".
I need all dates to be in this "01 January 2012" format without the time. There is not a format code in help that I can set to show this, does anyone know how I can change this.
I am not sure if this is enough info, if you need more then just shout please! Sorry if this is not helpful at all!
OUTSIDE A TEXT STRING:
FROM CASEEVENT E
JOIN CASES C ON E.CASEID = C.CASEID
WHERE E.EVENTNO = 196
AND C.IRN = :gstrEntryPoint
INSIDE A TEXT STRING:
select case when r.relationship is null
+ 'TEXTTEXTTEXT' + cast(ce.eventduedate as char)+ 'TEXTTEXTTEXT'
+ cast(DateAdd(Month, -1, ce.eventduedate)as char) + 'TEXTTEXTTEXT'
+ Char(10) end
from cases c
join relatedcase r on c.caseid=r.caseid
join caserelation cr on r.relationship=cr.relationship
join cases c2 on c2.caseid=r.relatedcaseid
join caseevent ce on ce.caseid=r.relatedcaseid
where c.propertytype = 'P'
and r.relationship = 'REC'
and c2.countrycode = 'HK'
and ce.eventno = 219
and c.irn =:gstrEntryPoint