Jump to content

Post date for yesterday


Mel
 Share

Recommended Posts

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

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

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 by Mel
Link to comment
Share on other sites

#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

  • Moderators

#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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...