Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Check if date is current date and stay current

Author  Topic 

opi
Starting Member

29 Posts

Posted - 2008-04-25 : 09:19:16
Hi,

I'm making some sort of application where people can add their resume.
They also need something to add places where they have worked or currently are working.

I have a form where they can add this and i add this experience using the following stored procedure:


GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_Insert_Experience]
@ExperienceId uniqueidentifier,
@ExperienceEmployee nvarchar(100),
@ExperienceFrom datetime,
@ExperienceUntil datetime,
@ExperienceQualifications nvarchar(250),
@ExperienceTechnologies nvarchar(250),
@ExperienceTasks nvarchar(250)
as
insert into Experiences
values(@ExperienceId,@ExperienceEmployee,@ExperienceFrom,@ExperienceUntil,@ExperienceQualifications,
@ExperienceTechnologies,@ExperienceTasks);


It must be possible to add the place where they currently are working. Then the ExperienceUntil has to be something like still going on. Then I decided that the user then had to set the current date.

But what I want is the following, I want that the ExperienceUntil keeps updating automatically, like everytime i get that record, it has to have current date.

Is this possible ?

But if the ExperienceUntil isn't the current date , it just had to take the supplied parameter date.

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-25 : 09:28:34
why don't you just allow the 'until' column to be null in the table? that's the true reflection of the situation eh? i.e. no end date yet

Em
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-04-25 : 09:33:39
that's true..
But would something like I want be possible in SQL server 2005
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 09:39:09
Only if you

1) Put a flag on the table denoting this record's date is to be forwarded
2) Write a job that takes care of the flag

But why make thing harder than it should be?
Follow Elancaster's advice and put either NULL or 'Dec 31, 9999' if you want the ExperienceUntil to be as is until further notice.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-04-25 : 10:45:18
jup that's the best solution, thanx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 10:50:47
Which of them?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

opi
Starting Member

29 Posts

Posted - 2008-04-27 : 03:38:39
the first
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-27 : 10:25:20
Wrong answer.
What happens if the job that forward the date by one day does not work for some reason?

The NULL or 'Dec 31, 9999' is a better choice because you never have to think about the date.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -