Jump to content
Sign in to follow this  
Mel

Post date for yesterday

Recommended Posts

Mel

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
Xenobiologist

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
Mel

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
Xenobiologist

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

#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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.