My overall goal is to take a date from excel, and compare it to the current date to get a day difference. My problem seems to stem from the format of each data point being different.
Today using A_Now is coming out as 20190402182124 and the format of the date in my excel sheet is 4/5/2019 12:00:00 AM. The spreadsheet cannot be manipulated, so any changes need to be done through AHK. I am expecting the outcome to be 3 days using the above example.
I have tried to convert the excel data to a better format, but it seems to be reverting to the current date, instead of changing the format, and I am not sure if I am mistaken on how the function works, or if I am just writing it incorrectly.
I have the message boxes just for checking to see if I am getting what I expect. Though the variable after the formattime function keeps reverting to the current date.
Code: Select all
TARGET_DELIVERY_DATE := "4/5/2019 12:00:00 AM" RegExMatch(TARGET_DELIVERY_DATE,"(\d+\/\d+\/\d+).*",TARGET_DELIVERY_DATE_CONVERTED) TARGET_DELIVERY_DATE_CONVERTED := TARGET_DELIVERY_DATE_CONVERTED1 MsgBox % TARGET_DELIVERY_DATE_CONVERTED FormatTime, TARGET_DELIVERY_DATE_CONVERTED,Mdyyyy, yyyyMMdd MsgBox % TARGET_DELIVERY_DATE_CONVERTED MsgBox % A_Now EnvSub, TARGET_DELIVERY_DATE_CONVERTED, %A_Now%, days MsgBox, %TARGET_DELIVERY_DATE_CONVERTED%
EDIT ---- I would still like to see if there is a way to fix this issue as stated above, but once I wrote everything out I just had the thought "why not just have AHK change the format of the spreadsheet through a comobject?" Which I did.
Code: Select all
xlApp.range("O:O").NumberFormat := "yyyymmdd"