sql server - sql subtract dates -


some of dates in column of dates recorded wrong. i'd make query subtracts 1 day each date if days in date range.

i know i'll have use dateadd , update, can't seem figure out. in advance.

this should it:

update  [sometable] set     [datecolumn] = dateadd(d, -1, [datecolumn])   [datecolumn] between [date1] , [date2] 

here's msdn doc's on dateadd function: http://msdn.microsoft.com/en-us/library/ms186819.aspx

when performing updates on data this, it's best run select statement first same criteria ensure you're updating correct records. helps reduce stress level of updating (especially if you're unfamiliar sql).

select    *, --depending on columns see, wildcard replaced           dateadd(d, -1, [datecolumn]) proposeddate      [sometable]     [datecolumn] between [date1] , [date2] 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -