Sign in to follow this  
Followers 0
ToyBoi

@mday, how to get the date number for yesterday?

11 posts in this topic

quick question here. @mday give you the date number for today, but what if you needed the date number for yesterday?

I tried this

$Date = _DateToDayValue (@YEAR, @MON, @MDAY)
$Date = $Date - 1

and then later on in my program

_IELinkClickByText ($oIE, $Date)
_IELoadWait ($oIE)

I got a no match error

Share this post


Link to post
Share on other sites



Use the Date UDF

#include <Date.au3>

$sNewDate = _DateAdd( 'd', -1, _NowCalcDate())

quick question here. @mday give you the date number for today, but what if you needed the date number for yesterday?

I tried this

$Date = _DateToDayValue (@YEAR, @MON, @MDAY)
$Date = $Date - 1

and then later on in my program

_IELinkClickByText ($oIE, $Date)
_IELoadWait ($oIE)

I got a no match error

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

_DateToDayValue()

Returns the Juliandate (days since noon 4713 BC January 1)

Is the text for that link 2454892.5 ?

Post an example of the link and we can help you.

EDIT:

Here is the test code for the above. Always test your code as you go.

#include <Date.au3>
$Date = _DateToDayValue (@YEAR, @MON, @MDAY)
$Date = $Date - 1
MsgBox(0, "Results", $Date)

And it could also have been written as

#include <Date.au3>
$Date = _DateToDayValue (@YEAR, @MON, @MDAY-1)
MsgBox(0, "Results", $Date)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

thanks to both for the help, both methods work find, I'm using

@mday-1
for simplicity. It's just a standard web based calendar that I was trying to work with. I didn't know what julian date meant. It seems pretty ridiculous then if _DateToDayValue() returns 2454892.5, I can't think of a situation where you would need such a function.

Edited by ToyBoi

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You may run into an issue with @mday - 1

What happens when @mday = 1?

Will 0 fit your needs still?

We still have not seen an example of the link data you are trying to match so we can't know for certain.

btw Julian dates can be very helpful when you are trying to figure out something like... Say you want to delete any file that is over 30 days old.... How do you compute the difference in age when you are talking about the turn of the month and or the turn of the year? converting current date and file date to julian gives you a proper reference to compare them to.

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

oh my god, you are right!

the problem with this calendar is that you can only click on the date that is yesterday, because this website only has yesterday's data, not today's, so today's date would be grayed out.

Posted Image

here is the picture, so then would you recommend

#include <Date.au3>
$sNewDate = _DateAdd( 'd', -1, _NowCalcDate())

or maybe that code has the same problem?

or maybe worst comes to worst, maybe i can say if @mday= 1 then $date = 31 or something

Edited by ToyBoi

Share this post


Link to post
Share on other sites

Post a link to that page. There will be a way to get it, I'm just not sure what it is without seeing the source for the page.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

i don't think I can, because it is in a private corporate network, but if you look at the calendar,the dates that aren't grayed out from 26 to 18, are clickable, and you can use IEclicklinkbytext.

If I wanted to go to the previous month, I can simply use a link from the site in the form of http:// ............ monthID=1 and that will take me to January

Edited by ToyBoi

Share this post


Link to post
Share on other sites

i don't think I can, because it is in a private corporate network, but if you look at the calendar,the dates that aren't grayed out from 26 to 18, are clickable, and you can use IEclicklinkbytext.

If I wanted to go to the previous month, I can simply use a link from the site in the form of http:// ............ monthID=1 and that will take me to January

Can you post that portion of the html that includes the calendar? it's probably contained in a <div> tag so post that div if you can.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Can you post that portion of the html that includes the calendar? it's probably contained in a <div> tag so post that div if you can.

</div>
                <div id="form_caldiv" class="form_cell_label">
                  <input type="radio" name="report_period" id="rpd" value="daily" checked onclick="document.chart_data.report_csv.value='false';document.chart_data.submit();" /><label for="rpd"> Daily</label>
                  <input type="radio" name="report_period" id="rpw" value="weekly"  onclick="document.chart_data.report_csv.value='false';document.chart_data.submit();" /><label for="rpw"> Weekly</label>
                  <input type="radio" name="report_period" id="rpm" value="monthly"  onclick="document.chart_data.report_csv.value='false';document.chart_data.submit();" /><label for="rpm"> Monthly</label>
                  <table class="month">
<tr><td class="monthnavigation" colspan="2"><a href="/index.php?yearID=2009&amp;monthID=2"><span class="monthnav">&lt;&lt;</span></a></td><td class="monthname" colspan="3">Mar 2009</td><td class="monthnavigation" colspan="2"><a href="/index.php?yearID=2009&amp;monthID=4"><span class="monthnav">&gt;&gt;</span></a></td></tr>
<tr><td class="dayname">M</td><td class="dayname">T</td><td class="dayname">W</td><td class="dayname">T</td><td class="dayname">F</td><td class="dayname">S</td><td class="dayname">S</td></tr>
<tr><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="event"><a href="java script:document.chart_data.selected_date.value='2009-03-01';document.chart_data.report_csv.value='false';document.chart_data.submit();">1</a></td></tr>
<tr><td class="selectedevent"><a href="java script:document.chart_data.selected_date.value='2009-03-02';document.chart_data.report_csv.value='false';document.chart_data.submit();">2</a></td><td class="today">3</td><td class="monthday">4</td><td class="monthday">5</td><td class="monthday">6</td><td class="saturday">7</td><td class="sunday">8</td></tr>
<tr><td class="monthday">9</td><td class="monthday">10</td><td class="monthday">11</td><td class="monthday">12</td><td class="monthday">13</td><td class="saturday">14</td><td class="sunday">15</td></tr>
<tr><td class="monthday">16</td><td class="monthday">17</td><td class="monthday">18</td><td class="monthday">19</td><td class="monthday">20</td><td class="saturday">21</td><td class="sunday">22</td></tr>
<tr><td class="monthday">23</td><td class="monthday">24</td><td class="monthday">25</td><td class="monthday">26</td><td class="monthday">27</td><td class="saturday">28</td><td class="sunday">29</td></tr>
<tr><td class="monthday">30</td><td class="monthday">31</td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td><td class="nomonthday"></td></tr>
</table>
                </div>

                  <div id="form_sdvdiv" class="form_cell_label">
                  <table width="100%">
                    <tr>
                      <td align="left"><span class="form_label">SDV Server(s)</span></td>
                      <td align="right">
                        <input class="form_text_small" type="text" size="4" name="sdv_search" onkeypress="keyEvent(event,'sdv_name[]',this.value);">
                        <input class="form_submit_small" type="button" name="sdv_find" value="Find" onclick="findSDV('sdv_name[]',document.chart_data.sdv_search.value);">
                      </td>
                    </tr>
                  </table>
                  <nobr>

Is this what you are looking for? This is today's calendar, March 3rd. My selection was "daily" instead of "weekly"

Posted Image

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Thats it but I think we better leave this for Dale to look at. They are using Javascript to get it.

The date format they are looking for is Year-Month-Day. I just don't think that _IELinkClickByText () will do it but Dale will know for sure

BTW

$Date would be

$Date = @Year & "-" & @Mon & "-" & @MDay-1

But you would still have to do some error checking and correction in case the day was 1

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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