![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I am creating creating a table with a Date column dd-mm-yyyy. But I cant seem to find a SQL function that just returns today's date. getDate() returns the time as well so I cant use it. The reason is simply that I want to update/overwrite over and over again all records from current day but not touch the ones from yesterday etc and with the timestamp in there I just end up adding more and more rows for the same day. In other words I only want to preserve rows are from yesterday or older but overwrite ones from today. Any help will be appricated. Thank you! Yas |
#3
| |||
| |||
|
|
Hi, I am creating creating a table with a Date column dd-mm-yyyy. But I cant seem to find a SQL function that just returns today's date. getDate() returns the time as well so I cant use it. The reason is simply that I want to update/overwrite over and over again all records from current day but not touch the ones from yesterday etc and with the timestamp in there I just end up adding more and more rows for the same day. In other words I only want to preserve rows are from yesterday or older but overwrite ones from today. Any help will be appricated. Thank you! Yas |
#4
| |||
| |||
|
|
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. |
#5
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |