Convert GetFileDate

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
obfusc88
Pro Scripter
Posts: 87
Joined: Wed Mar 14, 2007 6:22 pm

Convert GetFileDate

Post by obfusc88 » Sun Sep 22, 2024 6:05 am

FileDate gets DATE = 20240921
DatePart>DATE,Y = Year = 57317

Here is the simple code. %Original% is a valid file, checked that it exists earlier in script.

Code: Select all

Label>Get Original Date/Time
FileDate>%Original%,Date
FileTime>%Original%,Time

Label>ParseDate
DatePart>Date,y,Year
DatePart>%Date%,m,Month
DatePart>%Date%,d,Day
Actual file date is 9/21/2024 (Saturday)
This is from Stepping thru code:
Day = 3
Month = 10
Year = 57317
===========================
None of these values are correct.
Normal GetDate works normally. Only the DatePart is messing up.

Thanks.
Could these be internal dates that are different from what I see in Explorer?
Makes no sense to me.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Convert GetFileDate

Post by Dorian (MJT support) » Sun Sep 22, 2024 7:15 am

GetFileDate : The date returned is in the format YYYYMMDD

DatePart : The date should be in a format recognised by the system.

We can use MidStr though.

Code: Select all

filedate>%Original%,fd

MidStr>%fd%,1,4,yr
MidStr>%fd%,5,2,mn
MidStr>%fd%,7,2,dt
Yes, we have a Custom Scripting Service. Message me or go here

obfusc88
Pro Scripter
Posts: 87
Joined: Wed Mar 14, 2007 6:22 pm

Re: Convert GetFileDate

Post by obfusc88 » Tue Sep 24, 2024 12:11 am

Was writing response, when I stumbled across another idea. Found the problem.
I had a variable used as %Date% that should have been Date without the % ends.
Thanks for listening. Problem is gone.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts