NewbieAussieScripter Posted October 8, 2007 Share Posted October 8, 2007 (edited) G'day. I thought this would be easy but am having trouble with the logic. I need to work out the date of the previous weeks Monday and the previous Sunday for a report. ie: The report is run on say Tuesday 18 September 2007. I need to figure out how to get the date for the Monday in the previous week (10 Sptember 2007) and the Sunday after (16 September 2007). I'm assuming if I can work out the Monday's date, I could just do something like RETURN (@DAY + 6) or some such. I'm bamboozled. Please help. Cheers. Edited October 8, 2007 by NewbieAussieScripter Link to comment Share on other sites More sharing options...
Achilles Posted October 8, 2007 Share Posted October 8, 2007 Welcome to the AutoIt forums! A general piece of advice here is to post the code you're having problems with so that other people can fully understand your problem and what you're trying to do. I think that would be a good suggestion for this time. However, I'll try to think of something in a second. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Nahuel Posted October 8, 2007 Share Posted October 8, 2007 look for 'date.au3' in the help file. I'm sure you can do it with those UDF's Link to comment Share on other sites More sharing options...
NewbieAussieScripter Posted October 8, 2007 Author Share Posted October 8, 2007 look for 'date.au3' in the help file. I'm sure you can do it with those UDF's Thanks Nahuel. I had a look and thought I could use some combination of DateDiff and NowDateCalc but have become lost. This is why I'm putting in this request for help. Most of the answers I read in this forum have been plain to understand which is what I need. Reading the Help file and reviewing the date.au3 file showed me that I should be able to do it but cannot figure out the logic of what I need to do. Link to comment Share on other sites More sharing options...
McGod Posted October 8, 2007 Share Posted October 8, 2007 (edited) #include <Date.au3> Local $sDate = _DateAdd ( "D", -7, _NowCalc ()) MsgBox(1, "One week ago today", $sDate) #include <Date.au3> Local $sDate = _DateAdd ( "D", -7, _NowCalc ()) MsgBox(1, "One week ago", _DateTimeFormat($sDate, 1)) This one should be what your looking for. Edited October 8, 2007 by Chip [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
NewbieAussieScripter Posted October 8, 2007 Author Share Posted October 8, 2007 #include <Date.au3> Local $sDate = _DateAdd ( "D", -7, _NowCalc ()) MsgBox(1, "One week ago today", $sDate) #include <Date.au3> Local $sDate = _DateAdd ( "D", -7, _NowCalc ()) MsgBox(1, "One week ago", _DateTimeFormat($sDate, 1)) This one should be what your looking for. Thanks Chip. This is kind of what I had in mind and would certainly work if the report was run on a Monday. However, it is not always run on the same day each week. Usually, it is run on a Tuesday but sometimes it can be Thursday before it is run. Therefore the "-7" would produce an incorrect result. So I guess, in refining my question, how do I verify that the date returned is in fact, the Monday from the previous week? I would also like to add my sincere thanks for the speed and constuctive support from the community here. I must admit, being "Down Under", I thought I'd be waiting until tomorrow at the earliest for a response. This is helping me an awful lot. Thanks again, Bonk. Link to comment Share on other sites More sharing options...
enaiman Posted October 8, 2007 Share Posted October 8, 2007 you could take a look also in the help file at macros - here is the content:Macro Reference - Time And DateBelow is a list of Time and Date macros. Notice that most return values are two-digits long.The full list of macros can be found here. Macro Description @SEC Seconds value of clock. Range is 00 to 59 @MIN Minutes value of clock. Range is 00 to 59 @HOUR Hours value of clock in 24-hour format. Range is 00 to 23 @MDAY Current day of month. Range is 01 to 31 @MON Current month. Range is 01 to 12 @YEAR Current four-digit year @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. @YDAY Current day of year. Range is 1 to 366 (or 365 if not a leap year)You can see that @WDAY is very useful for what you have in mind SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
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