Sign in to follow this  
Followers 0
ioliver

How to find Yesterday?

6 posts in this topic

Is there a way to find out Yesterday's date (YYYYMMDD)? I look throught the Macro Reference - Time And Date section of the Help File, but I can't figure out how to do the calculations to get Yesterday's date.

Any help is apperciated.

Thanks,

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites



Is there a way to find out Yesterday's date (YYYYMMDD)?  I look throught the Macro Reference - Time And Date section of the Help File, but I can't figure out how to do the calculations to get Yesterday's date.

Any help is apperciated.

Thanks,

Ian

<{POST_SNAPBACK}>

Download the DateNew.au3 from my autoit stuff page and put it into the autoit3\include directory.

#include <DateNew.au3>
$yesterday = _DateAdd('d', -1, @YEAR & "/" & @MON & "/" & @MDAY)
MsgBox(4096, 'debug:', '$yesterday:' & $yesterday);### Debug MSGBOX

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

Download the DateNew.au3 from my autoit stuff page and put it into the autoit3\include directory.

#include <DateNew.au3>
$yesterday = _DateAdd('d', -1, @YEAR & "/" & @MON & "/" & @MDAY)
MsgBox(4096, 'debug:', '$yesterday:' & $yesterday);### Debug MSGBOX

<{POST_SNAPBACK}>

Thanks... It works great.

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites

I need to do two things.

#1 - go back 13 calander days

#2 - format the return values as MMDDYY

I used this DateNew.au3 and it works great, but it would sure be neater if I had an array. I just can't figure out how to make one.

Anyone care to assist?

:idiot:

#include <DateNew.au3>

$Bck_1 = _DateAdd('d', -1, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_2 = _DateAdd('d', -2, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_3 = _DateAdd('d', -3, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_4 = _DateAdd('d', -4, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_5 = _DateAdd('d', -5, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_6 = _DateAdd('d', -6, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_7 = _DateAdd('d', -7, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_8 = _DateAdd('d', -8, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_9 = _DateAdd('d', -9, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_10 = _DateAdd('d', -10, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_11 = _DateAdd('d', -11, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_12 = _DateAdd('d', -12, @YEAR & "/" & @MON & "/" & @MDAY)
$Bck_13 = _DateAdd('d', -13, @YEAR & "/" & @MON & "/" & @MDAY)

$B1_M1 = StringRight($Bck_1, 5)
$B1_M2 = StringLeft($B1_M1, 2)
$B1_D1 = StringRight($Bck_1, 2)
$B1_Y1 = Stringleft($Bck_1, 4)
$B1_YY = StringRight($B1_Y1, 2)

$B2_M2 = StringRight($Bck_2, 5)
$B2_M2 = StringLeft($B2_M2, 2)
$B2_D2 = StringRight($Bck_2, 2)
$B2_Y2 = Stringleft($Bck_2, 4)
$B2_YY = StringRight($B2_Y2, 2)

$B3_M3 = StringRight($Bck_3, 5)
$B3_M3 = StringLeft($B3_M3, 2)
$B3_D3 = StringRight($Bck_3, 2)
$B3_Y3 = Stringleft($Bck_3, 4)
$B3_YY = StringRight($B3_Y3, 2)

$B4_M4 = StringRight($Bck_4, 5)
$B4_M4 = StringLeft($B4_M4, 2)
$B4_D4 = StringRight($Bck_4, 2)
$B4_Y4 = Stringleft($Bck_4, 4)
$B4_YY = StringRight($B4_Y4, 2)

$B5_M5 = StringRight($Bck_5, 5)
$B5_M5 = StringLeft($B5_M5, 2)
$B5_D5 = StringRight($Bck_5, 2)
$B5_Y5 = Stringleft($Bck_5, 4)
$B5_YY = StringRight($B5_Y5, 2)

$B6_M6 = StringRight($Bck_6, 5)
$B6_M6 = StringLeft($B6_M6, 2)
$B6_D6 = StringRight($Bck_6, 2)
$B6_Y6 = Stringleft($Bck_6, 4)
$B6_YY = StringRight($B6_Y6, 2)

$B7_M7 = StringRight($Bck_7, 5)
$B7_M7 = StringLeft($B7_M7, 2)
$B7_D7 = StringRight($Bck_7, 2)
$B7_Y7 = Stringleft($Bck_7, 4)
$B7_YY = StringRight($B7_Y7, 2)

$B8_M8 = StringRight($Bck_8, 5)
$B8_M8 = StringLeft($B8_M8, 2)
$B8_D8 = StringRight($Bck_8, 2)
$B8_Y8 = Stringleft($Bck_8, 4)
$B8_YY = StringRight($B8_Y8, 2)

$B9_M9 = StringRight($Bck_9, 5)
$B9_M9 = StringLeft($B9_M9, 2)
$B9_D9 = StringRight($Bck_9, 2)
$B9_Y9 = Stringleft($Bck_9, 4)
$B9_YY = StringRight($B9_Y9, 2)

$B10_M10 = StringRight($Bck_10, 5)
$B10_M10 = StringLeft($B10_M10, 2)
$B10_D10 = StringRight($Bck_10, 2)
$B10_Y10 = Stringleft($Bck_10, 4)
$B10_YY = StringRight($B10_Y10, 2)

$B11_M11 = StringRight($Bck_11, 5)
$B11_M11 = StringLeft($B11_M11, 2)
$B11_D11 = StringRight($Bck_11, 2)
$B11_Y11 = Stringleft($Bck_11, 4)
$B11_YY = StringRight($B11_Y11, 2)

$B12_M12 = StringRight($Bck_12, 5)
$B12_M12 = StringLeft($B12_M12, 2)
$B12_D12 = StringRight($Bck_12, 2)
$B12_Y12 = Stringleft($Bck_12, 4)
$B12_YY = StringRight($B12_Y12, 2)

$B13_M13 = StringRight($Bck_13, 5)
$B13_M13 = StringLeft($B13_M13, 2)
$B13_D13 = StringRight($Bck_13, 2)
$B13_Y13 = Stringleft($Bck_13, 4)
$B13_YY = StringRight($B13_Y13, 2)

MsgBox(4096, 'Debug', $B1_M2&$B1_D1&$B1_YY & @CRLF & $B2_M2&$B2_D2&$B2_YY & @CRLF & $B3_M3&$B3_D3&$B3_YY & @CRLF & $B4_M4&$B4_D4&$B4_YY & @CRLF & $B5_M5&$B5_D5&$B5_YY & @CRLF & $B6_M6&$B6_D6&$B6_YY & @CRLF & $B7_M7&$B7_D7&$B7_YY & @CRLF & $B8_M8&$B8_D8&$B8_YY & @CRLF & $B9_M9&$B9_D9&$B9_YY & @CRLF & $B10_M10&$B10_D10&$B10_YY & @CRLF & $B11_M11&$B11_D11&$B11_YY & @CRLF & $B12_M12&$B12_D12&$B12_YY & @CRLF & $B13_M13&$B13_D13&$B13_YY)

Two wrongs don't make a right, but three lefts do

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I need to do two things.

#1 - go back 13 calander days

#2 - format the return values as MMDDYY

I used this DateNew.au3 and it works great, but it would sure be neater if I had an array.  I just can't figure out how to make one.

Anyone care to assist? 

Something like this :idiot:

#include <DateNew.au3>
Dim $Bck[13]
Dim $msg = ""
For $x = 0 To 12
   $Bck[$x] = _DateAdd('D', -1 - $x, @YEAR & "/" & @MON & "/" & @MDAY)
   $n_DATE = StringMid($Bck[$x], 6, 2)                ;get month
   $n_DATE = $n_DATE & StringMid($Bck[$x], 9, 2)      ;get wday
   $Bck[$x] = $n_DATE & StringMid($Bck[$x], 3, 2)    ;get year and replace Array value
   $msg = $msg & $Bck[$x] & @CRLF                    ;add to msg for magbox
Next
MsgBox(4096, 'Debug', $msg)
Edited by JdeB

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

Incredible! Thanks a bunch!

I really need to figure out this array stuff. It absolutely confuses me no end!

:idiot:


Two wrongs don't make a right, but three lefts do

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