Switch or iff

  • Thread starter Thread starter Junior
  • Start date Start date
J

Junior

What's wrong with this switch statement? - i'm trying to use it in a select
query.
Currently it sets XcodeDte to [BegDate] whether datediff is <0 or >0. i've
also tried using iif statments but get the same results.

XCodeDte:
Switch(DateDiff("d",[PDueDte],[BegDate]<1),[BegDate],DateDiff("d",[PDueDte],
[BegDate]>1),[BegDate]-10)
 
The closing parentheses for both DateDiffs are in the
wrong place. The closing parentheses should be before the
test, ie ")<1" not "<1)".

Try using this:

XCodeDte: Switch(DateDiff("d",[PDueDte],[BegDate])<1,
[BegDate],DateDiff("d",[PDueDte],[BegDate])>1,[BegDate]-10)


HTH

Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


-----Original Message-----
What's wrong with this switch statement? - i'm trying to use it in a select
query.
Currently it sets XcodeDte to [BegDate] whether datediff
is said:
also tried using iif statments but get the same results.

XCodeDte:
Switch(DateDiff("d",[PDueDte],[BegDate]<1), [BegDate],DateDiff("d",[PDueDte],
[BegDate]>1),[BegDate]-10)


.
 
Thanks - thought it must be the syntax -
SteveS said:
The closing parentheses for both DateDiffs are in the
wrong place. The closing parentheses should be before the
test, ie ")<1" not "<1)".

Try using this:

XCodeDte: Switch(DateDiff("d",[PDueDte],[BegDate])<1,
[BegDate],DateDiff("d",[PDueDte],[BegDate])>1,[BegDate]-10)


HTH

Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


-----Original Message-----
What's wrong with this switch statement? - i'm trying to use it in a select
query.
Currently it sets XcodeDte to [BegDate] whether datediff
is said:
also tried using iif statments but get the same results.

XCodeDte:
Switch(DateDiff("d",[PDueDte],[BegDate]<1), [BegDate],DateDiff("d",[PDueDte],
[BegDate]>1),[BegDate]-10)


.
 
Back
Top