Sign in to follow this  
Followers 0
Mel

Post date for yesterday

7 posts in this topic

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")

Share this post


Link to post
Share on other sites



This is very simple if you use the date UDF :D

#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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Mel

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#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.

Share this post


Link to post
Share on other sites

Thanks guys I got it. You guys are like batman!

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