cancel
Showing results for 
Search instead for 
Did you mean: 

comparing a date field with a fixed date in variable

former_member611722
Participant
0 Kudos

Hi,
can someone please help me with the following:

I want to say:

=If [In Production Date] >= "2015-12-14" Then "Closed" Else "Open"

But, I keep getting this error: The expression or sub-expression at position 28 in the '>=' function uses an invalid data type. (IES 10037).
Any idea how to fixit?

Thanks,

Accepted Solutions (0)

Answers (3)

Answers (3)

mhmohammed
Active Contributor
0 Kudos

Hi Nina,

Try this

=If([In Production Date]>= ToDate("8/20/17"; "d/M/yy")) Then "Closed" Else "Open"

Thanks,
Mahboob Mohammed

mhmohammed
Active Contributor
0 Kudos

Hi Nina,

You need to use ToDate() function.

=If[In Production Date]>= ToDate("12/14/2015";"dd/MM/yyyy") Then "Closed" Else "Open"

You can use the date format similar to In Production Date.

https://blogs.sap.com/2016/07/28/formatdate-and-todate-a-simple-guide/

Thanks,
Mahboob Mohammed

former_member611722
Participant
0 Kudos

Mohammed,
I did the following but it did not work. Please note that I only have the last 2 digits of the year

=If [In Production Date]>= ToDate("8/20/17"; "dd/MM/yy") Then "Closed" Else "Open"
I have dates like this: 5/1/17; 8/20/17, ..

Thanks,

omacoder
Active Contributor
0 Kudos

What data type is [In Production Date] and is it a string?

Because you're comparing it to a string "2015-12-14"

If it's not a string, format your fixed date as a date type

former_member611722
Participant
0 Kudos

The data type is date. Can you please tell me how I should do that?

Thanks

omacoder
Active Contributor
0 Kudos

Check in your list of functions. There should be a formatdate or similar function that you will need to format your string fixed date to the same date format as [In Production Date]