Friday, February 17, 2012

Delete Question

Hi:
I have conttructed the following query to delete all records from a table if
a Reservation date is older than the current date:
Delete From ConfRoomSchedule
Where DateReserved < GetDate
The syntax checks out fine but when I run it, I get an error stating that
GetDate is not a valid column.
What am I doing wrong?
Thanks
BrennanPlease change the query to following:
Delete From ConfRoomSchedule
Where DateReserved < GetDate()
"Brennan" wrote:

> Hi:
> I have conttructed the following query to delete all records from a table
if
> a Reservation date is older than the current date:
> Delete From ConfRoomSchedule
> Where DateReserved < GetDate
> The syntax checks out fine but when I run it, I get an error stating that
> GetDate is not a valid column.
> What am I doing wrong?
> Thanks
> Brennan|||Thank You
"Absar Ahmad" wrote:
> Please change the query to following:
> Delete From ConfRoomSchedule
> Where DateReserved < GetDate()
> "Brennan" wrote:
>|||I hope you are aware that getdate() will include the current time also. Thus
if you run the statement at 6:00 PM on a day, this will also delete the rows
inserted before 6:00 PM on that day.
You can use any of the following queries to get Current Date with 00:00:00
Hours as the time:
select convert(datetime,convert(varchar(10),get
date(),103),103)
select dateadd(d,floor(convert(float,getdate(),
103)),'19000101')
"Brennan" wrote:
> Thank You
> "Absar Ahmad" wrote:
>|||Its a function:
getdate()
MC
"Brennan" <Brennan@.discussions.microsoft.com> wrote in message
news:CDD9834F-ABE0-4047-AA9C-99856370AA7D@.microsoft.com...
> Hi:
> I have conttructed the following query to delete all records from a table
> if
> a Reservation date is older than the current date:
> Delete From ConfRoomSchedule
> Where DateReserved < GetDate
> The syntax checks out fine but when I run it, I get an error stating that
> GetDate is not a valid column.
> What am I doing wrong?
> Thanks
> Brennan

No comments:

Post a Comment