Jump to content
rony2006

One day ahead - data format generation

Recommended Posts

rony2006

Hello guys,

I really have a problem that I cannot solve and I need your support.

 

I need 2 variable: $StartDate and $EndDate.

$StartDate I generate it simple with the following code:

$StartDate = StringReplace(_NowCalcDate(),"/", "")

 

$EndDate should be one day ahead so now I calculate it using:

Local $sNewDate = _DateAdd('d', 1, _NowCalcDate())
$EndDate = StringReplace($sNewDate,"/", "")

 

The problem is that when current date is for ex. 31.10.2017, enddate will be 32.10.2017 which will generate an error for me.

 

I tried following code to solve this:

if $EndDate = 32 Then
$EndDate = 1
Endif

But the problem is that sometime current month is only 30 days, so enddate will be 31 which doesn't exist in current month which will also generate an error.

 

How can I generate $EndDate and also to have a valid year, month and day that actually exist and is a day ahead in calendar? 

Share this post


Link to post
Share on other sites
Jos
2 minutes ago, rony2006 said:

The problem is that when current date is for ex. 31.10.2017, enddate will be 32.10.2017 which will generate an error for me.

This will not happen as _DateAdd() handles that properly and will return 2017/11/1 assuming the input was 2017/10/31.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
rony2006
4 minutes ago, Jos said:

This will not happen as _DateAdd() handles that properly and will return 2017/11/1 assuming the input was 2017/10/31.

Jos

Thanks. So means that also month will be changed? for example 30.09.2017 is last day from September. If I add + 1 day to 30.09.2017 using _DateAdd() then EndDate will be 01.10.2017?

Share this post


Link to post
Share on other sites
iamtheky

just do the thing...  heres one for 6 days from now

#include<date.au3>
Local $sNewDate = _DateAdd('d', 1, "2017/10/31")
$EndDate = StringReplace($sNewDate,"/", "")
msgbox(0, '' ,$EndDate)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Jos
1 minute ago, rony2006 said:

So means that also month will be changed?

So that means you didn't try, didn't check the helpfile and just assumed something? ;)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
rony2006

Sorry guys,

 

I didn't thought that AutoIT can handle this.

I really love AutoIT. After I finish my project and I will get paid, I will donate.  

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

×