missing arguments
DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 19, -1, 0), 18) And DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 19, 0, 1), 18)
missing arguments
DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 19, -1, 0), 18) And DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 19, 0, 1), 18)
No nothing at all. And also the experession that you gave me first works fine (except the calculation) The expression that you first gave me works with no errors I mean.
Maybe it's the context within which it's used. Can you provide some insight on that?
There was missed Date function in my example formulas (and abundant brackets for Date functions, but Access must remove them automatically). Here is an example of working test procedure
Code:Public Sub Test() Dim datTest1 As Date Dim datTest2 As Date datTest1 = DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 18, -1, 0), 18) datTest2 = DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 18, 0, 1), 18) End Sub
HBi , Thanks for that. Unfortunately this gives a data mismatch error which is puzzling. Should the second line have a different < sign?There was missed Date function in my example formulas (and abundant brackets for Date functions, but Access must remove them automatically). Here is an example of working test procedure
Code:Public Sub Test() Dim datTest1 As Date Dim datTest2 As Date datTest1 = DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 18, -1, 0), 18) datTest2 = DateSerial(Year(Date), Month(Date) + IIf(Day(Date) < 18, 0, 1), 18) End Sub
I did think of that , and so created a new data base with made up table and data with the same result.
So I have a table with records that have a date field. Creating a query that extracts the records according to the expression that we are writing here.
What is puzzling is that the first one you did works as far as the data is concerned, it just needs the extra Iif expression
Can you post that DB here, to provide a non-working example?I did think of that , and so created a new data base with made up table and data with the same result.
Having spent far too much time than the problem warrented I manged to sort it out and get an understanding of the < logic you used.
What I ended up with was :-
Between DateSerial(Year(Date()),Month(Date())+IIf(Day(Date ())<18,-1,0),18) And DateSerial(Year(Date()),Month(Date())+IIf(Day(Date ())<18,0,1),18)
Just needed the extra brackets after Date in the Iif Function.
Thanks for your help.
HI,
Cracked it eventually.
Between DateSerial(Year(Date()),Month(Date())+IIf(Day(Date ())<18,-1,0),18) And DateSerial(Year(Date()),Month(Date())+IIf(Day(Date ())<18,0,1),18)
Missing the extra brackets after Date in the Iif function.
Many Thanks for your help
Don't know why, but Access sometimes removes the () when I include it in the date() function.
Glad you got it sorted out.