Jump to content

Example OF dates


stiv
 Share

Go to solution Solved by Musashi,

Recommended Posts

Hello

fellow autoit.

I have two questions, 
the first is, it is possible to put the date in a variable.
using <Date.au3>.

    
the second is, it is possible to add two days to the date in a variable.
using <Date.au3>.
for example today is 2022/04/18. and what I want to put is 2022/04/20.
 

Please could you give me examples.

Thank you very much
 


 

Link to comment
Share on other sites

1) Which date do you want to store in a variable? The current date? Including Time?

2) How would you name a function that adds dates? Did you hava a look at the list of functions the Date UDF provides? As always: the help file is your friend :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Again have a look at the list of functions the Date UDF provides. There is a function that provides the current date/time. Assign the result of this function to a variable. Done :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Solution
2 hours ago, stiv said:

1. is it possible to put the (current) date in a variable using <Date.au3>

2. is it possible to add two days to the (current) date in a variable using <Date.au3> for example 2022/04/18 -> 2022/04/20.

 

#include <Date.au3>
Local $sCurrentDate, $sNewDate
$sCurrentDate = _NowCalcDate()  ; current date in format YYYY/MM/DD
$sNewDate     = _DateAdd('d', 2, $sCurrentDate) ; current date + 2 days
MsgBox(4096, "Show Dates : ", "Current "& @TAB & "= "  & $sCurrentDate & @CRLF & _
                              "NewDate "& @TAB & "= "  & $sNewDate & @CRLF)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

You are lucky that Musashi provided code for all of your questions 🙂
Usually we do not spoon feed users with solutions. We help users to find solutions themselfes.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

23 hours ago, stiv said:

is it possible to put the date in a variable.

#include <Date.au3>
$date = _NowCalcDate()

    
is it possible to add two days to the date in a variable, for example today is 2022/04/18. and what I want to put is 2022/04/20.

#include <Date.au3>
$date = _DateAdd('d', 2, _NowCalcDate())

 

these are basically straight from the documentation
https://www.autoitscript.com/autoit3/docs/libfunctions/_DateAdd.htm
https://www.autoitscript.com/autoit3/docs/libfunctions/_NowCalcDate.htm

Edited by lIlIIlIllIIIIlI
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...