Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Trying to write an if statement with GetCurrentSelections:
If(GetFieldSelections(Week)= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)
my date format is 01/26/2018
Please let me know if you have any ideas on how to get it working.
Thanks!
Adding a Date() formatting function to the left side will not work, since the value you want to format is a text value.
Try interpretation function Date#()
Erica,
What is your output? The expression looks like OK (considering that field Week is formated as you said).
Cheers
I'm guessing there is a timestamp attached to your field, but you're only concerned about the date. You can use floor() to ignore the timestamp. This formula should work:
If(Floor(GetFieldSelections(Week)) = Floor(Weekend(Today())),1,0)
Outputs:
GetCurrentSelections(Week): Week:01/27/2018
Date(Weekend(Today()),'MM/DD/YYYY'): 01/27/2018
I have also tried 'Week:'&Date(Weekend(Today()),'MM/DD/YYYY'): Week:01/27/2018
as
If(GetFieldSelections(Week)= 'Week:'&Date(Weekend(Today()),'MM/DD/YYYY'),1,0) and that still didn't work
Your construction of the weeend date seems to be correct;
but GetFieldSelections(Week) do not return the Week date but sthing like
Week: 01/26/2018
so ur condition has to be sthing like :
if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)
per anaogy result if condition is:
if(trim(SubField( GetCurrentSelections(Year),':',2))=max({1}Year),1,0)
else
It seems you have a date field formated as a timestamp, as Nicole said. Try Nicole's expression and then tell us what happens.
Cheers
I have the week selected and I used:
if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)
and its still giving me a zero, I also tried:
if(Date(trim(SubField( GetCurrentSelections(Week),':',2)))=Date(Weekend(Today()),'MM/DD/YYYY'),1,0)
and its still a zero.
Its strange, I both fields into a text object to see their outputs and they are exactly the same, I'm not sure why it refuses to match.
The right value shows a leading zero, and you are comparing the text values char by char.
Adding a Date() formatting function to the left side will not work, since the value you want to format is a text value.
Try interpretation function Date#()
what if u try as :
if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'M/DD/YYYY'),1,0)
OR
if(trim(SubField( GetCurrentSelections(Week),':',2))= Date#(Weekend(Today()),'M/DD/YYYY'),1,0)