Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


stevja01
2025-05-29T17:03:04Z
Any ideas how to create a variable for an Epoch Date?
For example: the epoch timestamp 1687818708818 = June 26, 2023
Sponsor
Forum information
bweston
2025-06-05T16:47:09Z
Took me a moment to realize the reason my first attempt got an arithmetic overflow was because your number is in milliseconds - not seconds, which I believe is the standard expectation for a unix timestamp.

Naturally, you're gonna need to be sure which you're dealing with for this to work.

{DATEADD(Seconds|1970-01-01 00:00:00Z|u|{MATH(Divide|Double|1687818708818|1000|#0)}|yyyy-MM-dd)}
stevja01
2025-06-11T19:57:31Z

How would I setup a variable though to come up with FRIDAY's date in EPOCH so the correct file will be downloaded.

For example:
FILE_1687818708818.txt

I want to setup 1678718708818 as a variable for the FILE MASK. Hope that makes sense.
bweston
2025-06-13T14:48:10Z
Well, I do get now that you are trying to go in the opposite direction from what I thought, and might need to hold an exorcism for whoever decided on that filename convention, but now you've suggested that you want to get Friday's date as a Unix timestamp so that you can download a particular filename, and your example timestamp is a specific time (down to the millisecond) in late evening on a Monday.

Part of the reason I assumed you were trying to get from the timestamp to the date is because the date isn't enough information to come up with that timestamp; if you asked me for the unix timestamp of Monday, June 26, 2023 I would give you 1687737600. And then after you specified you wanted milliseconds I'd say "...so add three zeroes at the end."

It sounds like a situation in which I would be checking the files available for download and really hoping I could successfully filter them by created or modified date instead of by filename. If I absolutely had to work from the filenames, I'd probably try to list them first, then take that list into Powershell and manipulate it to figure out which file I wanted; because even having to round-trip the information into Powershell and back to VisualCron, I'd be much more comfortable with that tooling than with trying to get from a list of filenames with unix timestamps in them to which file has a timestamp in its name that is from a particular date.

That said, if I were given a date (we'll take 2023-06-26 as an example) and wanted to get the Unix timestamp, with milliseconds, for midnight of the preceding Friday in UTC using pure VisualCron variable expressions...let's see. I guess this would do it?

{MATH(Add|Double|86400000|{MATH(Multiply|Double|{MATH(Divide|Integer|{DATE(DaysBetween|1970-01-02|2023-06-26)}|7|#0)}|604800000|#0)}|#0)}


...Find the number of days between January 2 1970 (since that was a Friday) and the given date, divide by 7 to get weeks and throw away the remainder, multiply by the number of milliseconds in a week, and add the number of milliseconds in a day to make up for starting one day after the epoch. I'm not sure if that's the best or easiest way, but it was the most natural way for me to think about it.
Scroll to Top