You need to sign in to do that
Don't have an account?
zigzag
Convert a DateTime field to a Date?
I am trying to create a formula field to hold the day of week; the cookbook helpfully suggests the following nifty formula:
MOD(MyField__c - DATE(1900, 1, 7), 7)
Unfortunately, this only works if MyField__c is a Date field, and not if it is a DateTime field. It seems silly, but I cannot for the life of me figure out how to convert one to the other - why does it not just do it automatically?
As far as I can tell, none of the date functions work on a DateTime, so I can't just brute force it by extracting the year, month and day to create a new Date like this:
DATE(YEAR(MyField__c), MONTH(MyField__c), DAY(MyField__c)
Any advice? Hopefully there is a workaround - surely a DateTime is just a Date that also has a timestamp attached to it...
Thanks
MOD(MyField__c - DATE(1900, 1, 7), 7)
Unfortunately, this only works if MyField__c is a Date field, and not if it is a DateTime field. It seems silly, but I cannot for the life of me figure out how to convert one to the other - why does it not just do it automatically?
As far as I can tell, none of the date functions work on a DateTime, so I can't just brute force it by extracting the year, month and day to create a new Date like this:
DATE(YEAR(MyField__c), MONTH(MyField__c), DAY(MyField__c)
Any advice? Hopefully there is a workaround - surely a DateTime is just a Date that also has a timestamp attached to it...
Thanks
DATEVALUE(MyField__c)
returns a Date value that I can work with. Why DATE(MyField__c) doesn't just do the right thing I don't know though :)
Thanks,
Allan