mschol Posted July 24, 2007 Share Posted July 24, 2007 i need to do the following: i need to fill in a date on a website. but the date to fill in depends on the current date: example: 1 when its tuesday 24-07-07 i need to fill in 23-07-07 (monday) but 2 when its monday 23-07-07 i need to fill in 20-07-07 (friday) how do i do that with autoit? (i need the values (day/month/year) as separate variables) Link to comment Share on other sites More sharing options...
ptrex Posted July 24, 2007 Share Posted July 24, 2007 @mschol This calculates 2 days back from today. #include<date.au3> $iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY) $NextMonday = _DateAdd("d",-2-$iWeekday,_NowCalcDate()) ConsoleWrite('Next Monday is ' & $NextMonday & @crlf ) regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
mschol Posted July 24, 2007 Author Share Posted July 24, 2007 @mschol This calculates 2 days back from today. #include<date.au3> $iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY) $NextMonday = _DateAdd("d",-2-$iWeekday,_NowCalcDate()) ConsoleWrite('Next Monday is ' & $NextMonday & @crlf ) regards ptrex 1: the example you gave gives back 2007-07-21 which is 3 days ago and i think you dont get what i need to have: i need to find the last work day based on the current date, so: if today is monday then get date of last friday if today is tuesday then get date of last monday if today is wednesday then get date of last tuesday if today is thursday then get date of last wednesday if today is friday then get date of last thursday hope this makes my question a little clearer Link to comment Share on other sites More sharing options...
Developers Jos Posted July 24, 2007 Developers Share Posted July 24, 2007 (edited) The example posted goes back to the last Monday.. This goes back 2 days from today: #include<date.au3> $day = _DateAdd("d",-2,_NowCalcDate()) ConsoleWrite('Two days agoy is ' & $day & @crlf ) Edited July 24, 2007 by JdeB 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. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2007 Share Posted July 24, 2007 (edited) 1: the example you gave gives back 2007-07-21 which is 3 days ago and i think you dont get what i need to have: i need to find the last work day based on the current date, so: if today is monday then get date of last friday if today is tuesday then get date of last monday if today is wednesday then get date of last tuesday if today is thursday then get date of last wednesday if today is friday then get date of last thursday hope this makes my question a little clearer Try this: #include<date.au3> $day = _PreviousWorkDay() ConsoleWrite('Last work day was: ' & $day & @crlf ) Func _PreviousWorkDay() Local $Offset Switch @WDAY Case 1 $Offset = -2 Case 2 $Offset = -3 Case Else $Offset = -1 EndSwitch Return _DateAdd("d", $Offset, _NowCalcDate()) EndFunc Edited July 24, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mschol Posted July 24, 2007 Author Share Posted July 24, 2007 Try this: #include<date.au3> $day = _PreviousWorkDay() ConsoleWrite('Last work day was: ' & $day & @crlf ) Func _PreviousWorkDay() Local $Offset Switch @WDAY Case 1 $Offset = -2 Case 2 $Offset = -3 Case Else $Offset = -1 EndSwitch Return _DateAdd("d", $Offset, _NowCalcDate()) EndFuncoÝ÷ Ûú®¢×§Ç¢Ø^槶)Ê%½çb¶X¤zØb±«¢+ØÀÌØí¥]äô}ÑQ½å=]%M with the complete date in the $date array 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