Doubt about query
I'm having a little trouble to perform a query.
I have a table named "tbl_Date" with the following fields "DATE_1" and "Date_2" (the fields are date type).
How do I know the records where the dates of the field "Date_2" are 15 working days more useful that the dates of the field "DATE_1"
What you mean with "more useful"? Probably knowing this may help defining what you want, but I would be looking to use the DateAdd function: http://www.techonthenet.com/access/f...te/dateadd.php
This function would allow you to add 15 week days to the initial date and make a comparison, probably allowing you to know what you need to know.
Just to add to Rui suggestion if a value is calculated, which appears to be the case with your Date_2, by convention it should not be stored in a table but created when needed in a query. This keeps the tables simpler and insures against data errors where someone changes Date_1 and not Date_2 or just changes Date_2. :cheers:
Rui and RetiredGeek, thanks for the help.
I tried these three expressions using the function ADDDATE, but all it shows a syntax error message:
Expr1: DateAdd ("d", "15", #DATE_1#)
Expr1: DateAdd ('d', 15, [DATE_1])
Expr1: DateAdd ("d", 15, [DATE_1])
Please, where am I going wrong?
Rui meant that I'm trying to get only those records where the value is
in the field "Data_2" is greater than "Data_1".
In this case the date field "Data_2" is 15 days (useful - workdays
) larger than the date field "Data_1"
The correct format for use in a query is:
Expression used for the graphic above: FollowUp: DateAdd("d",15,[DeceasedDte])
FYI: If you are after only working days you should see this MS Article.
See the attached image. I put the word exactly as you showed me. Sorry, the error message is in Portuguese:
The expression you entered contains invalid syntax. You omitted an operand or operator, entered an invalid character or comma, or inserted without text enclose it in quotes.
Is the data type of the Date_1 field Date/Time? Or Text? :cheers:
Date_1 and Date_2 are Date/Time!Attachment 33509
Can you go into SQL View and then copy all the SQL and paste it here?
Sorry, but I'm at a loss. Everyting works on my end and I can't see anything wrong with what you are doing. :angry:
Here's the SQL:
SELECT Hospital.PatientNo, Hospital.LName, Hospital.FName, Hospital.DeceasedDte, DateAdd("d",15,[DeceasedDte]) AS FollowUp
Rui and RetiredGeek,Attachment 33515
I found the reason: I was using comma (,) to separate function parameters
must use the semicolon (;).
Simply withdraw the (;) and only put (,) does not work. (See the picture)
See, I'm using the wizard in design view, and not directly in making
Maybe it's because my access is in Portuguese, not sure.
But the important thing is that now worked perfectly, many thanks for help
I'm trying to show the sign of semicolons, but is getting a face (happy image)
Yes, the forum code does have that behavior. You can go around it (and I just did, but if you edit the post again, the changes to avoid it are removed).
Anyway, I am glad you solved your problem.