DigDeep Posted January 25, 2018 Posted January 25, 2018 Is there a way to change both the below formats into mm/dd/yyyy? The time mentioned if does not change / cannot change is fine as the time format is already set for me. 1. from Jan 25, 2018 9:23:56 PM to 1/25/2018 9:23:56 PM 2. from 1/25/18 to 1/25/2018 From the 2nd point above, I tried one way as per below but I am getting the year as /0018 instead of /2018. $GetDate = FileReadLine($DateFile, 1) Local $aDate0 = StringSplit($GetDate, "/") Local $aDate = StringFormat("%02d/%02d/%04d", $aDate0[1], $aDate0[2], $aDate0[3]) MsgBox(0, '', $aDate) = 1/26/0018
iamtheky Posted January 25, 2018 Posted January 25, 2018 (edited) Im making an additional assumption that it would be dates in the past not future, so the 80s and 90s would refer to the 1900s not the aughts. $GetDate = "1/25/18" ;~ $GetDate = "1/25/99" Local $aDate0 = StringSplit($GetDate, "/") Local $aDate = stringright($GetDate , 2) < stringleft(@Year , 2) ? StringFormat("%02d/%02d/20%d", $aDate0[1], $aDate0[2], $aDate0[3]) : StringFormat("%02d/%02d/19%d", $aDate0[1], $aDate0[2], $aDate0[3]) MsgBox(0, '', $aDate) Also, something like this might satisfy both 1 and 2: #include<date.au3> $GetDate = "Jan 25, 2018" ;~ $GetDate = "Sep 5, 2018" For $i = 1 to 12 If _DateToMonth($i , 1) = stringleft($GetDate , 3) Then msgbox(0 , '' , stringformat("%02d" , $i) & "/" & stringformat("%02d" , stringmid($GetDate , stringinstr($GetDate , " ") , stringinstr($GetDate , ",") - stringinstr($GetDate , " "))) & "/" & stringright($GetDate , 4)) Exit EndIf Next Edited January 25, 2018 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
abdulrahmanok Posted January 25, 2018 Posted January 25, 2018 (edited) wrong post Edited January 25, 2018 by abdulrahmanok
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now