Sign in to follow this  
Followers 0
yucatan

_date

28 posts in this topic

Hello guys

today it wensday 17 november.

i wanne write a script.

that i get all date's of the week.

monday 15 november

truesday 16 november

wensday 17 november

etc

all days of this week with the date so 17 november .

is this possible.

how should i do this?

Share this post


Link to post
Share on other sites



Check out the date management in the help file. it has everything you need for dates/times

yeah i know that..

i already tryed that..

Share this post


Link to post
Share on other sites

This gives all the days of the current week starting with monday:

For $iIndex = 1 To 7
    $sdate = _DateAdd("d", (@WDAY*-1) + $iIndex + 1, @YEAR & "/" & @MON & "/" & @MDAY)
    ConsoleWrite($sdate & @CRLF)
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

_DateDayOfWeek(@WDAY)

will write out the current day of the week

@WDAY will give you a number 1-7, 1=Sunday, 2=Monday etc.

_DateAdd

_DateDiff

_NowCalcDate

Will return the date in format YYYY/MM/DD

_DateToMonth

Writes out name of the month 1-12, 1=January

That should be more than enough to get you going


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

This gives all the days of the current week starting with monday:

For $iIndex = 1 To 7
    $sdate = _DateAdd("d", (@WDAY*-1) + $iIndex + 1, @YEAR & "/" & @MON & "/" & @MDAY)
    ConsoleWrite($sdate & @CRLF)
Next

Nice great men,

one more question.

is it possible to hang this on _WeekNumberISO

because what if i wanne do this but then i wanne use week 50 as info.

i wanne request all dates of week 50?

Share this post


Link to post
Share on other sites

_WeekNumberISO returns the week number.

I would start with the 1st of January, check for the target weeknumber and increment if necessary using _DateAdd.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

_WeekNumberISO returns the week number.

I would start with the 1st of January, check for the target weeknumber and increment if necessary using _DateAdd.

i'm sorry i dont fully understand ur post.

Share this post


Link to post
Share on other sites

i'm sorry i dont fully understand ur post.

To my knowledge there is no function available that returns the start date (monday) of a given week number.

So I suggest to start with 2010/01/01. Use _WeekNumberISO to get the week number for this date and compare it to the desired week number (50 in your case).

If the week number has not reached the target week increment the date using _DateAdd.

Run this in a loop.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

To my knowledge there is no function available that returns the start date (monday) of a given week number.

So I suggest to start with 2010/01/01. Use _WeekNumberISO to get the week number for this date and compare it to the desired week number (50 in your case).

If the week number has not reached the target week increment the date using _DateAdd.

Run this in a loop.

do u have a sample code maby?

i know i can

#include <Date.au3>

$data = _WeekNumberISO("2011","6","14")
ConsoleWrite($data)

i know that i can calc the weeknumber when i have the date.

i should create a loop that i runs it with all dates.

put it in a array.

i only dont know what is the best way to do this in a loop.

Edited by yucatan

Share this post


Link to post
Share on other sites

do u have a sample code maby?

Unfortunately not.

But given the needed functions in my last post it shouldn't be too hard.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

i know i'm trying.

just cant figure it out.

Share this post


Link to post
Share on other sites

Quick & Dirty:

Global $sStartdate = "2010/01/01"
Global $iTargetWeek = 50
While 1
    $aDate = StringSplit($sStartdate, "/")
    $iWeek = _WeekNumberISO($aDate[1], $aDate[2], $aDate[3])
    If $iWeek <> $iTargetWeek Then
        $sStartDate = _DateAdd("d", 1, $sStartDate)
    Else
        ExitLoop
    EndIf
WEnd
ConsoleWrite("Week " & $iTargetWeek & " starts on " & $sStartDate & @CRLF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I was attempting to do something like:

#include <Date.au3>

$i=1

$data = _WeekNumberISO("2010",String($i),"1")

ConsoleWrite("WeekISO="&$data&@CRLF)

Do

$i+=1

$data = _WeekNumberISO("2011",String($i),"1")

ConsoleWrite("WeekISO="&$data&@CRLF)

Until $data>=50

However, something with that function is not right because this is the result I got:

WeekISO=52

WeekISO=5

WeekISO=9

WeekISO=13

WeekISO=17

WeekISO=22

WeekISO=26

WeekISO=31

WeekISO=35

WeekISO=39

WeekISO=44

WeekISO=48

WeekISO=-1

WeekISO=-1

WeekISO=-1...........etc. etc. etc.

*edit*

I know I should have set it up as

#include <Date.au3>

$i=0

Do

$i+=1

$data = _WeekNumberISO("2011",String($i),"1")

ConsoleWrite("WeekISO="&$data&@CRLF)

Until $data>=50

but then it stops at month 1 day 1 with a value of 52...

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

However, something with that function is not right because this is the result I got:

It depends on how you define "week number". Please check this.Or - even better - this. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It depends on how you define "week number". Please check this.Or - even better - this.

at this point i'm stuck at the point as kaotkbliss.

we still searching for a good way.

the sample u gived me works good.

but how can i discover the end date?

how can i let this loop for for more then one week number?

Share this post


Link to post
Share on other sites

That's confusing...

However, this will get the variable $data close to a desired week number

#include <Date.au3>

$input=InputBox("enter week number","")

$i=0

Do

$i+=1

$data = _WeekNumberISO("2011",String($i),"7")

ConsoleWrite("WeekISO="&$data&@CRLF)

Until $data>=Int($input)-7 And $data<=Int($input)+7


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

at this point i'm stuck at the point as kaotkbliss.

we still searching for a good way.

the sample u gived me works good.

but how can i discover the end date?

how can i let this loop for for more then one week number?

Come on - given the code in my last post this is quite easy.

My code returns the first day in the week you specify.

Increment the date 6 times and you have all dates of the required week!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Come on - given the code in my last post this is quite easy.

My code returns the first day in the week you specify.

Increment the date 6 times and you have all dates of the required week!

yeah that i understand.

but i need the start and end date of all weeks.

1 until 52.

if possible of different years.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Something to think about:

2010/01/01 is in week 52 of 2009. What do you want to get as a start of this week?

If you have Outlook, check the calender to see when a week starts and ends.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  
Followers 0