Copy link to clipboard
Copied
There are two functions I'm trying to have AE perform and it would be great to know if there are expressions that would make these possible. Since we're talking about calendar dates it's not a straight math problem. Here's what I'd like to be able to do
1. Create a Date from 3 inputted values (year, month, day)
2. Calculate the number of days between two such dates.
The functions: CreateDate and DateDiff would be perfect for this task but they both generate errors in the expression window ("[expression] is not a function").
Any insight would be greatly appreciated!
Copy link to clipboard
Copied
Maybe this will help you get started. https://community.adobe.com/t5/after-effects-discussions/looking-for-after-effects-expression-that-l...
Copy link to clipboard
Copied
Hmmm...it doesn't look like this is taking into account the different days of the month and leap years....am I missing something?
Copy link to clipboard
Copied
That expression is just a start. I don't have time to figure out the modifications for your specific requirements. Maybe Dan Ebberts will contribute something to the thread. He could probably do it without even opening AE.
Copy link to clipboard
Copied
I think something like this should work:
d1 = new Date('4/8/2022').getTime();
d2 = new Date('4/8/2023').getTime();
Math.ceil(Math.abs(d2-d1)/ (1000 * 3600 * 24));
Copy link to clipboard
Copied
Thanks Dan, this is very helpful! Is there a way to have the start and end dates be inputs linked to an expression control rather than a date that I would have to type into the expression box itself?
Copy link to clipboard
Copied
Like this maybe:
y1 = effect("Year 1")("Slider").value;
m1 = effect("Month 1")("Slider").value;
d1 = effect("Day 1")("Slider").value;
y2 = effect("Year 2")("Slider").value;
m2 = effect("Month 2")("Slider").value;
d2 = effect("Day 2")("Slider").value;
d1 = new Date(m1 + '/' + d1 + '/' + y1).getTime();
d2 = new Date(m2 + '/' + d2 + '/' + y2).getTime();
Math.ceil(Math.abs(d2-d1)/ (1000 * 3600 * 24));
Copy link to clipboard
Copied
Awesome! Thank you so much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now