Sign in to follow this  
Followers 0
falconv

Ideas to help simplify?

6 posts in this topic

#1 ·  Posted (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 by falconv

Share this post


Link to post
Share on other sites



#2 ·  Posted (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".

Edit

I 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 by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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! :P 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 by falconv

Share this post


Link to post
Share on other sites

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)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0