All Forums Database
darybrain 2 posts Joined 09/11
20 Sep 2011
Date division - why?

Hey gang,

I'm going through some old code to attempt some basic documentation (whats that I hear you say plus I didn't orginially create it and the person who did has gone walkabout) and I'm questioning the code below. Can anyone explain why you would do this type of division on a date column as its something I haven't seen before. Unless I'm missing a trick or something really obvious me no get it so why o why??

Field: -


Code: -

DELETE FROM Customer_Details_Copy
WHERE Load_date/100 <>
(SELECT Load_date/100
FROM Customer_Details

Thanks in advance (unles you can't help then well ....... )

Jimm 298 posts Joined 09/07
20 Sep 2011

A date field is held as an integer internally, formatted as yyymmdd (yyy is years since 1900, so start of this year is 1110101).

Divide by 100 removes the days, so your code get rid of Customer_Details_Copy rows which have a load date (yyyymm only) different from the load date (year/month) in Customer Details.

You will probably see lots of old code examples of datefld/100 * 100 + 1 - make a date into the start of the month. 


darybrain 2 posts Joined 09/11
20 Sep 2011

Thanks good to know.

You must sign in to leave a comment.