November 28, 2010 at 11:42 am
Hi
can anyone tell me why when i run the following i get an error message. I need to be able to insert dates as yyyy-mm-dd hh:mm:ss.
Many Thanks
Create table mfSitPosition
(
sitPosition int,
sitDateTime smalldatetime,
)
Go
Insert into mfSitPosition values (1234,2010-11-28 18:30:00 )
Many Thanks
November 28, 2010 at 11:47 am
p.stevens76 (11/28/2010)
Hican anyone tell me why when i run the following i get an error message. I need to be able to insert dates as yyyy-mm-dd hh:mm:ss.
Many Thanks
Create table mfSitPosition
(
sitPosition int,
sitDateTime smalldatetime,
)
Go
Insert into mfSitPosition values (1234,2010-11-28 18:30:00 )
Many Thanks
First, the date needs to be quoted like the following...
Insert into mfSitPosition values (1234,'2010-11-28 18:30:00')
Second, be really, really careful. Make sure that you're storing the dates in a DATETIME column and not a VARCHAR column. You're opening yourself up to a world-of-hurt and some real performance problems if you store dates and/or times as a VARCHAR.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 28, 2010 at 12:17 pm
Many Thanks, I posted a thread a couple of days ago about this but i think i over complicated the matter. Have a look if you want, you will see what i'm try to achieve ( i think??)
That has work fine, i now need to run a query against that date field to see if the date in the field is less than 30 minutes ago from the time the query is ran. Would i use the datediff function or is there another way???
If you can help, thaks in advance.
November 28, 2010 at 12:34 pm
Something like this?
SELECT sitPosition
FROM mfSitPosition
WHERE sitDateTime >DATEADD(MI,-30,GETDATE())
November 28, 2010 at 12:51 pm
Hi, many thanks for that, works fine.
i now need to put something in place so that if the date is >= 30 mins ago then a stored proc will run, if the date is within the 30 min period then no action.
i have the stored proc ready, it is the dates i was struggling with and the structure of whole process.
still fairly new to all this and am at a stage where i know what is possible but need examples to see how it all fits together.
Many thanks in advance
November 28, 2010 at 1:42 pm
p.stevens76 (11/28/2010)
Hi, many thanks for that, works fine.i now need to put something in place so that if the date is >= 30 mins ago then a stored proc will run, if the date is within the 30 min period then no action.
i have the stored proc ready, it is the dates i was struggling with and the structure of whole process.
still fairly new to all this and am at a stage where i know what is possible but need examples to see how it all fits together.
Many thanks in advance
It's time to introduce you to Books Online. Take a look at "IF"...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply