INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

inserting value(1000) in default value On a specific date

inserting value(1000) in default value On a specific date

(OP)
Hello,,,
I need insert value(1000) in default value On a specific date where (date-sal)= 01-07-2017 and 01/01/2017

RE: inserting value(1000) in default value On a specific date

I can't see any problem in what you are trying to do.

A default value can be any legal VFP expression. The only rule is that it must return the same data type as the parent field. Since your expression returns a numeric value, and the field in question (taba) is also numeric, it should work as expected.

What problem are you seeing? Is there an error message?

That said, while it should work for INSERT, it probably won't do what you want with APPEND BLANK, as the dependent field (date_sal) won't have a value at the point where the default kicks in.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: inserting value(1000) in default value On a specific date

(OP)
yes, the massege return error, can you tell me the right massege for this function

RE: inserting value(1000) in default value On a specific date

So what is the wording of the error message?

Also, please post the function code in your reply. It's difficult to read it from the screen shot that you posted.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: inserting value(1000) in default value On a specific date

(OP)
the message==
iif(date_sal=date(01/07/2017),1000,0)

RE: inserting value(1000) in default value On a specific date

Read the help topic on Date(): https://msdn.microsoft.com/en-us/library/aa977499%...

What you call message is your default value expression. With "message", Mike meant the error message you get displayed when trying to set that default value expression, but it helps to see the full expression, too, as the screenshot cuts that off and the selected line is unreadable for me on my large display, much too small. So thanks for that essential info, it always helps to provide code as text and not screenshot.

You simply make the wrong usage of the date() function, I initially linked to the definition you'd need to use.

A date literal - a date value needing no function like DATE() to be created - also is possible, that would have the format {^YYYY-MM-DD} in VFP, so perhaps the shortest possible way to do that is:
iif(date_sal={^2017-07-01},1000,0)

Your initial post indicates you want this for two dates, also for 01/01/2017, that could be done with an ICASE, which would also allow assigning different default values per date:
icase(date_sal={^2017-07-01},1000,date_sal={^2017-01-01},1000,0)
or for the same default you may use
iif(date_sal={^2017-07-01} OR date_sal={^2017-07-01},1000,0)

But surely you will not use
iif(date_sal={^2017-07-01} AND date_sal={^2017-07-01},1000,0)
or
iif(date_sal={^2017-07-01} AND {^2017-07-01},1000,0)

If you have any legacy VFP background, what you had in mind when you wrote date(01/07/2017) might have been CTOD('01/07/2017'), but I would not recommend that, as it depends on settings, different countries have different formats for dates, not only in the order of day and month. {^YYYY-MM-DD} is a universal way to write a date independent of such regional differences.

Bye, Olaf.

RE: inserting value(1000) in default value On a specific date

iif(date_sal=date(01/07/2017),1000,0) is wrong syntax for date(). Use

iif(date_sal=date(2017,1,7),1000,0) 

RE: inserting value(1000) in default value On a specific date

(OP)
thanks to all i will try it

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close