May 26, 2005 at 10:27 am
Hi All:
I've got a table with approximately 600 records, and one field that is date time. The date portion of the field is the same day with time portion incrementing as the records are inserted throughout the day. What i want to do is update the date portion of the field in that table leaving the time portion intact. So for example, the information in the table currently is yesterdays data, i want to update it to be today. I'm not quite sure how to go about doing this.
Any ideas? Greatly appreciated!
Thanks,
Ray
May 26, 2005 at 10:30 am
Update YourTable
Set YourDate = DateAdd(D, 1, YourDate)
May 27, 2005 at 12:55 am
try this:
update your_table
set date_field = convert(datetime,
convert(varchar, getdate(), 106) + ' ' + convert(varchar, date_field, 108),
0)
Leo
May 27, 2005 at 9:04 am
Raymond a quick question if the data is being updated daily as the rows are input then the Date field will be the current date and time that the row was updated (you can use getdate() for this). Are the records always updated at the same time every day? If not then how much impact will corrupting the data (not recourding the true time value) have? What happens if on a given date one of the rows is not inserted or an additional row is added to the table? If you only update the rows already in the table your data will not be correct.
Ron's solution is probably the best way to increment your data by one day. I was just woundering why you would want to do this when the correct day and time could be recorded when the rows are updated.
Mike
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply