# calculating date

## Recommended Posts

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)

##### Share on other sites

@mschol

This calculates 2 days back from today.

```#include<date.au3>
\$iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY)
ConsoleWrite('Next Monday is ' & \$NextMonday & @crlf )```

regards

ptrex

##### Share on other sites

@mschol

This calculates 2 days back from today.

```#include<date.au3>
\$iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY)
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

##### Share on other sites

The example posted goes back to the last Monday..

This goes back 2 days from today:

```#include<date.au3>
ConsoleWrite('Two days agoy is ' & \$day & @crlf )```
Edited by JdeB

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

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
EndFunc```

Edited 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

##### Share on other sites

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
EndFuncoÝ÷ Ûú®¢×§Ç¢Ø^æ§¶)Ê%½çb¶X¤zØb±«­¢+ØÀÌØí¥]­äô}ÑQ½å=]­%M```

with the complete date in the \$date array

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...