Jump to content

One day ahead - data format generation


 Share

Recommended Posts

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? 

Link to comment
Share on other sites

  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)

 

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

Link to comment
Share on other sites

  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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