May 14, 2003 at 4:02 pm
i have several instances, applications running in a machine. Is there a way to change the date in one instance or database alone, so that I can frequently change the dates and test it. Thanks in advance.
May 14, 2003 at 4:26 pm
Interesting question.
Not that I am aware of, maybe define a function which returns the date/time with your date/time offset applied and use it in the place of GetDate().
May 14, 2003 at 4:36 pm
Thanks. Do you think I can create a function called getdate(), which will overrule the sytemwide getdate() function. Or will my instance crash, when I compile it?
May 15, 2003 at 4:10 pm
It is not working. I created a function, but i cannot do select getdate() on it. This function needs to be invoked like a stored procedure. Any other way ? Just dont want to touch the OS date.
May 15, 2003 at 5:24 pm
Try a view
Create view Test as Select DateAdd(hh,2,GetDate()) as TheDate
I have used 2 hours as an offset value.
May 15, 2003 at 5:45 pm
Not the best, but seems to be working.
CREATE VIEW Test as Select DateAdd(hh,2,GetDate()) as TheDate
GO
CREATE FUNCTION TestDate()
Returns @TheTable TABLE ([GETDATE] DateTime) as
BEGIN
Insert @TheTable
Select TheDate From Test
RETURN
END
GO
CREATE FUNCTION TestDateII()
Returns DateTime
BEGIN
RETURN (Select [GetDate] from dbo.TestDate())
END
GO
Select dbo.TestDateII()
GO
Suspect the overhead will make it a bit slow, maybe OK for testing!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply