What's fastest way to replace simple date function?

FIELD Yr:=Yr;x:=@Now;

Year:=@If(@Month(@Now)=1;-1;0);

z:=@Adjust(x;0;0;0;0;0;0);

@SetField(“Yr”;z);

SELECT @All

I used the above formula in my agent to replace value in my date field, Yr, to 1 Jan 2007,problem is that it takes long time to load. I wonder can I make simple formula into replace the value in this field to 1 Jan 2007.

the Yr is a date field.

tq in advance :slight_smile:

Subject: What’s fastest way to replace simple date function ?

Your formula makes no sense - all you are doing is setting the field Yr to today’s date, but you say that you’re trying to set the field Yr to 1 Jan 2007.

What exactly are you trying to do?

If you are trying to change a value of a field to 1 Jan 2007 then you just need:

FIELD Yr:=@date(2007;01;01)

Dan

Subject: RE: What’s fastest way to replace simple date function ?

tq Dan , I just want to change the year to 2007, but since the field comes with day and month, it can be today’s date or 1 Jan.

tq for your tip

Subject: RE: What’s fastest way to replace simple date function ?

Then use:

FIELD Yr:=@date(2007;@month(Yr);@day(Yr))

Or, if you’re trying to change the date to the current year (which might make more sense):

FIELD Yr:=@date(@year(@today);@month(Yr);@day(Yr))

Dan

Subject: RE: What’s fastest way to replace simple date function ?

Then use:

FIELD Yr:=@date(2007;@month(Yr);@day(Yr))

Or, if you’re trying to change the date to the current year (which might make more sense):

FIELD Yr:=@date(@year(@today);@month(Yr);@day(Yr))

Dan

Subject: RE: What’s fastest way to replace simple date function ?

tq Dan, I was thinking like maybe need to put value such as 36400, i.e some kind of math conversion for data. i tried to search for help one whole night on how does the conversion work, but it seems probably this explanation is no longer relevant with @date formula. Just interested to go back to basic, once a while :slight_smile:

Subject: What’s fastest way to replace simple date function ?

FIELD Yr := [01/01/2007];

Subject: What’s fastest way to replace simple date function ?

FIELD Yr := [01/01/2007];

Subject: What’s fastest way to replace simple date function ?

Your formula makes no sense - all you are doing is setting the field Yr to today’s date, but you say that you’re trying to set the field Yr to 1 Jan 2007.

What exactly are you trying to do?

If you are trying to change a value of a field to 1 Jan 2007 then you just need:

FIELD Yr:=@date(2007;01;01)

Dan