falconv Posted October 4, 2005 Posted October 4, 2005 (edited) This works just fine, so unless someone has an idea to simplify this, I'm fine with it in my script. I've just noticed that I tend to do things the hard way, and it'd be nice to see ideas of simplifying, so someday I'll get used to it and do things the easy way naturally. anyway, cutting to the chase, here's *my* way of doing this (I want to take the date 3 weeks from _NowCalcDate() and change the format to 2-digit day followed by 3-letter month, ie 24Oct) #include <Date.au3> $date1 = _DateTimeFormat(_NowCalcDate(),1) ;Get today's date $remove_left = StringInStr($date1,",") ;how much to take from left to remove the day $date2 = StringTrimLeft($date1, $remove_left + 1);remove the day of the week $date_mo = StringLeft($date2, 3) ;Grab the 1st 3 letters of the month $date3 = StringTrimRight($date2, 6) ;remove the year $date_day = StringRight($date3, 2) ;grab the 2-digit date $date = $date_day & $date_mo ; put the two together MsgBox( 4096, "MY Short Format", $date)Thanks in advance for any ideas! Edited October 4, 2005 by falconv
BigDod Posted October 4, 2005 Posted October 4, 2005 (edited) This works just fine, so unless someone has an idea to simplify this, I'm fine with it in my script. I've just noticed that I tend to do things the hard way, and it'd be nice to see ideas of simplifying, so someday I'll get used to it and do things the easy way naturally.anyway, cutting to the chase, here's *my* way of doing this (I want to take the date 3 weeks from _NowCalcDate() and change the format to 2-digit day followed by 3-letter month, ie 24Oct)#include <Date.au3> $date1 = _DateTimeFormat(_NowCalcDate(),1);Get today's date $remove_left = StringInStr($date1,",") ;how much to take from left to remove the day $date2 = StringTrimLeft($date1, $remove_left + 1);remove the day of the week $date_mo = StringLeft($date2, 3) ;Grab the 1st 3 letters of the month $date3 = StringTrimRight($date2, 6) ;remove the year $date_day = StringRight($date3, 2) ;grab the 2-digit date $date = $date_day & $date_mo ; put the two together MsgBox( 4096, "MY Short Format", $date)Thanks in advance for any ideas!I am not sure that your script does what you describe. When I run it I get a msgbox with "be4 O".EditI now have it with the correct date format but not the 3 week part.#include <Date.au3> $date1 = _DateTimeFormat(_NowCalcDate(),1);Get today's date $remove_left = StringInStr($date1,",");how much to take from left to remove the day $date2 = StringTrimLeft($date1, $remove_left + 3);remove the day of the week $date_mo = StringLeft($date2, 3);Grab the 1st 3 letters of the month $date3 = StringTrimRight($date2, 6);remove the year $date_day = StringRight($date1, 2);grab the 2-digit date $date = $date_day & $date_mo; put the two together MsgBox( 4096, "MY Short Format", $date) Edited October 4, 2005 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
Developers Jos Posted October 4, 2005 Developers Posted October 4, 2005 try: #include<date.au3> @MDAY & _DateMonthOfYear(@MON, 1) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Bert Posted October 4, 2005 Posted October 4, 2005 tried it, and I got "0505". What are you trying to do? The Vollatran project My blog: http://www.vollysinterestingshit.com/
falconv Posted October 4, 2005 Author Posted October 4, 2005 (edited) @BigDod - It uses your system's settings for "Long Date Format", so if you're not using "Tuesday, October 04, 2005" format it won't come out right because it'd be chopping off the wrong parts when it uses StringLeft and such (you can use MsgBox(4096, "Pc Long format", _DateTimeFormat( _NowCalc(),1)) to see what your long date format is set as. don't forget to include Date.au3) @JdeB - Sweet, thank you!! That's ingenious! I hope soon I'll know AutoIt well enough to come up with something like that the 1st time Now to check to make sure it will work with _DateAdd 3 weeks @vollyman - maybe you put it in wrong? I tried it and it came out "04Oct" now I just need to figure out how to get it to say "25Oct" on the 4th, and "01Nov" on the 11th, etc. Edited October 4, 2005 by falconv
Developers Jos Posted October 4, 2005 Developers Posted October 4, 2005 I hope soon I'll know AutoIt well enough to come up with something like that the 1st time Now to check to make sure it will work with _DateAdd 3 weeks#include<date.au3>Dim $tdate,$ttime$tdate = _DateAdd("w",3,_NowCalcDate())$tMM = StringMid($tdate,6,2)$tdd = StringMid($tdate,9,2)$Fdate = $tdd & _DateMonthOfYear($tmm, 1) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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