Check for todays date

Last Post 23 Nov 2011 05:27 AM by Derek Colley. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
JASBRYDEN
New Member
New Member

--
02 Feb 2011 06:42 AM
Hi

I need some help please

below is the table rtm_customerservice


Date varchar(10)
RouteNo varchar(6)
RouteCustomers numeric(18, 0)
ServiceCustomers numeric(18, 0)
MerchCustomers numeric(18, 0)
Not_Service numeric(18, 0)
[%Merchandised] numeric(18, 0)
[%Not_Service] numeric(18, 0)


I need a query that does the following:-

First check the date in the file to see if it is todays date, if YES then we leave it, if NO we change it to todays date.


Please help me create one.

Thanks


rm
New Member
New Member

--
02 Feb 2011 09:07 AM
Where's file? How do you check date in the file?
russellb
New Member
New Member

--
02 Feb 2011 10:00 AM
And WHY in the world are you using a Varchar(10) to store dates? Using proper data types will save you lots of headaches down the road.
Derek Colley
New Member
New Member

--
23 Nov 2011 05:27 AM

DECLARE @foodate VARCHAR(10)
SET @foodate = CONVERT(VARCHAR(10),CURRENT_DATE)
UPDATE rtm_customerservice
  SET date = CONVERT(VARCHAR(10),CURRENT_DATE)
  WHERE @date <> @foodate
GO


This assumes your formatting of the varchar date column in rtm_customerservice matches the smalldatetime format of the CURRENT_TIME system variable.

If not you have some gluing and sticking ahead of you...



Acceptable Use Policy
---