Mel Posted April 16, 2008 Share Posted April 16, 2008 We currently use the below code for yesterdays date but it does not work on the first of the month so we use 1/31/08 I would like to change this so on the first it reflects th last day of the previous month. Please assist.... $mm = @MDAY - 1 $yy = @YEAR - 2000 If $mm < 10 Then $PDate = @MON & "0" & $mm & "0" & $yy If $mm > 10 Then $PDate = @MON & "" & $mm & "0" & $yy If $mm = 10 Then $PDate = @MON & "" & $mm & "0" & $yy If $mm = 00 Then $PDate = ("013108") Link to comment Share on other sites More sharing options...
monoceres Posted April 16, 2008 Share Posted April 16, 2008 This is very simple if you use the date UDF #include <date.au3> $now=_NowCalc() MsgBox(0,"",$now) $yesterday=_DateAdd("D",-1,$now) MsgBox(0,"",$yesterday) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 16, 2008 Share Posted April 16, 2008 Hi, #include <Date.au3> ConsoleWrite(_DateAdd('d','-1', _NowCalcDate()) & @CRLF) Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Mel Posted April 16, 2008 Author Share Posted April 16, 2008 (edited) Not exactly what I needed but it's a start. I need the output to be "041508". The output is 2008/04/15 12:22:17. Do you know of a quick fix. Edited April 16, 2008 by Mel Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 16, 2008 Share Posted April 16, 2008 #include <Date.au3> $date = _DateAdd('d','-1', _NowCalcDate()) $date = StringMid($date, 6,2) & StringRight($date, 2) & StringMid($date, 3,2) ConsoleWrite($date & @CRLF) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 16, 2008 Moderators Share Posted April 16, 2008 #include <date.au3> MsgBox(0, 0, _DateDaysAgo()) MsgBox(0, 0, _DateDaysAgo(2)) MsgBox(0, 0, _DateDaysAgo(3)) Func _DateDaysAgo($nDaysAgo = 1) Local $szDiff = _DateAdd("d", "-" & $nDaysAgo, _NowCalcDate()) Local $szPattern = "(\d+)/(\d+)/(\d+)" Local $aSRE = StringRegExp($szDiff, $szPattern, 1) Return $aSRE[1] & $aSRE[2] & StringTrimLeft($aSRE[0], 2) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Mel Posted April 16, 2008 Author Share Posted April 16, 2008 Thanks guys I got it. You guys are like batman! 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