You need to sign in to do that
Don't have an account?
business Identity
Compare a CreatedDate (This is of type DateTime) and a variable MyCustomDateVariable (This is of type Date) in SOQL
Hello People,
I need to compare a CreatedDate (This is of type DateTime) and a variable MyCustomDateVariable (This is of type Date) in SOQL. I have tried with following attempts.But doesn't work:
1) DAY_ONLY(CreatedDate)=:MyCustomDateVariable
2) Date.valueOf(CreatedDate)=:MyCustomDateVariable
3) CreatedDate=:DateTime.valueOf(MyCustomDateVariable)
Thanks...
I need to compare a CreatedDate (This is of type DateTime) and a variable MyCustomDateVariable (This is of type Date) in SOQL. I have tried with following attempts.But doesn't work:
1) DAY_ONLY(CreatedDate)=:MyCustomDateVariable
2) Date.valueOf(CreatedDate)=:MyCustomDateVariable
3) CreatedDate=:DateTime.valueOf(MyCustomDateVariable)
Thanks...
pbattisson
You cannot compare those 2 types in SOQL directly using any of those methods, what I would suggest is (assuming you are only interested in the Date component) adding a date field on the object that you set via a default value or workflow and then compare using that. This will make your queries faster than any of the methods you have as well.
John Pipkin
the DAY_ONLY function should work. It sounds like there is something else wrong with your query. Have you tried manually running the query in workbench or dev console to ensure that your query returns records?