|
Posted by Yas on 07/04/07 15:55
On 4 Jul, 17:14, Roy Harvey <roy_har...@snet.net> wrote:
> To remove the time from a datetime such as getdate():
>
> SELECT dateadd(day,datediff(day,0,getdate()),0)
>
> I strongly suggest not storing a date column as a string. Use a
> datetime and just set the time to zeroes if you only need the date.
Hi I am storing the coumn as datetime and not string. However, using
the above suggestion (day,datediff(day,0,getdate()),0) I get a column
with Date+Time set to Zeros. OK, but the problem is when I run the
update/insert records command again It doesn't overwrite the columns
with today's date, its as if sql is secretly inserting the time by it
self and even though to my eyes the rows is exactly the same SQL adds
a new row thinking it is distinct.
I would like that if the table had a rowOld with: (ColValue1,
ColValue2,2007-07-04 00.00.00.000)
If I use the above suggestion and insert a rowNew with same values
(ColValue1, ColValue2, 2007-07-04 00.00.00.000)
....It should overwrite rowOld with rowNew, not insert rowNew as a new
row.
....and only insert as a new rowNew2 when this row has a different date
eg. 2007-07-05 00.00.00.000
I thought it would as time is now set to Zeros, but it doesn't. Is SQL
marking each row in the examples above with a time stamp? even though
it is not shown in the row value?
Thanks again :-)
Yas
Navigation:
[Reply to this message]
|