Feeds:
Posts
Comments

Archive for January, 2013

Declare @Month as Int

Set @Month=2

SELECT VisitID,PatientID,ImageId,Trans_No,DATEADD(DAY, DATEDIFF(DAY, VisitDate,
CONVERT(DATETIME, CAST(YEAR(VisitDate) AS VARCHAR(4))
+ RIGHT(‘0’+CAST(DAY(VisitDate) AS VARCHAR(2)),2) +
+ RIGHT(‘0’+CAST(MONTH(VisitDate) AS VARCHAR(2)),2), 112)), VisitDate) As VDate
From SN_Visits_Image
Where Year(VisitDate)=2013 And Day(VisitDate)=1 And Month(VisitDate)=@Month
Update SN_Visits_Image Set VisitDate = VT.VDate
From
SN_Visits_Image SVI Inner join
(
SELECT VisitID,PatientID,ImageId,ImageFileName,Trans_No,DATEADD(DAY, DATEDIFF(DAY, VisitDate,
CONVERT(DATETIME, CAST(YEAR(VisitDate) AS VARCHAR(4))
+ RIGHT(‘0’+CAST(DAY(VisitDate) AS VARCHAR(2)),2) +
+ RIGHT(‘0’+CAST(MONTH(VisitDate) AS VARCHAR(2)),2), 112)), VisitDate) As VDate
From SN_Visits_Image
Where Year(VisitDate)=2013 And Day(VisitDate)=1 And Month(VisitDate)=@Month
) VT on
SVI.VisitID = VT.VisitID And SVI.PatientID = VT.PatientID And SVI.ImageId = VT.ImageId And SVI.ImageFileName = VT.ImageFileName
And SVI.Trans_No = VT.Trans_No

 

Read Full Post »