Jump to content
fmtdonnk

days of week for a date

Recommended Posts

fmtdonnk

Hello

 

What is the function to get the week number of a certain date

 

for example I have a date

 

$sDate ="2018/05/5"

I would like to know if it's a Monday or Wednesday?

 

thanks


Franck

 

 

 

 

Share this post


Link to post
Share on other sites
fmtdonnk

Hello

 

What is the function to get the week number of a certain date

 

for example I have a date

 

$sDate ="2018/05/5"

I would like to know if it's a Monday or Wednesday?

 

thanks


Franck

 

 

 

 

Share this post


Link to post
Share on other sites
JLogan3o13

@fmtdonnk did you happen to notice the very clear statement at the top of the Examples forum? We even bolded it for you:

Quote

Do not post general support questions here, instead use the AutoIt Help and Support forums.

Please pay attention to where you post in the future.

As to your question - did you try looking in the help file? There is an entire section on Date Management where you'll find your answer pretty quickly.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
jchd

Also note that your date isn't in the correct format for processing: it should have a leading zero for 1..9. Months & days need to have two digits each.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
fmtdonnk

you mean under script and example?

By the way, finaly this is not working

I try this

$sDate ="2018/5/22"

Local $sLongDayName = _DateDayOfWeek($sNewDate)

but I get an error

when 

 

Local $sLongDayName = _DateDayOfWeek(@WDAY) it's working but I want to change the @WDAY 

 

THanks


 

 

 

Share this post


Link to post
Share on other sites
jchd

Again, your date format is wrong.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
fmtdonnk

Seems not wrong to me

 

in the same  script I have this , and it's working fine

==================================

$sDate ="2018/5/22"
For $x = 1 To 2
Local $sNewDate = _DateAdd('d', $x, $sDate)
MsgBox($MB_SYSTEMMODAL, "", "Today + 5 days: " &  $sNewDate)
 
Next
=================================
 
I see that the date increase by one day
 
I just need to check if it's Saturday or Sunday! and I stuck for 1 one hour for a stupid syntax I am sure from my side
 

Share this post


Link to post
Share on other sites
fmtdonnk

thanks for your time

 

Share this post


Link to post
Share on other sites
jchd

You're lucky single-digit month or day work in this case, but this point is clearly specified differently in the help file. That means things could stop working this way in some future release without notice (wouldn't be considered a script-breaking change). I for one wouldn't rely on this. Also date without leading zeroes (non-ISO) are a serious risk for sorting and interoperability.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
fmtdonnk

ok I change and put a correct date format

==========================

$sDate ="2017/12/30"
For $x = 1 To 3
Local $sNewDate = _DateAdd('d', $x, $sDate)
Local $sLongDayName = _DateDayOfWeek($sDate)
MsgBox($MB_SYSTEMMODAL, "", "the date is : " &  $sNewDate & $sLongDayName)
 
Next
 
=============================
 
DateAdd working very good
but the DateDayOfWeek no.
I don't get any error, just don't nothing showing me the Week Day
 
I get
The date is : 2017/12/31
The date is : 2018/01/01
The date is : 2018/01/02
 
 
Do you have an idea how I can check if a date in the loop  is a Saturday or Sunday??
 
Thanks
 
Franck

Share this post


Link to post
Share on other sites
jchd

You're misusing the _DateDayOfWeek function: it doesn't do what you believe it does.

Local $sDate ="2018/05/30"
Local $sNewDate, $aYMD, $iDoW, $sLongDayName
For $x = 0 To 3
    $sNewDate = _DateAdd('D', $x, $sDate)
    $aYMD = StringSplit($sNewDate, "/", 2)
    $iDoW = _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2])
    $sLongDayName = _DateDayOfWeek($iDoW, 2)
    MsgBox($MB_SYSTEMMODAL, "", "The date is : " &  $sNewDate & " " & $sLongDayName)
Next

 

  • Like 1

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Earthshine
Posted (edited)

I found this in online help

https://www.autoitscript.com/autoit3/docs/libfunctions/_DateToDayOfWeekISO.htm

which will return numbers for days of week 1= Monday to 7 = Sunday, so, if it's 6 or 7 from this function that could be one way.

The example directly above works perfectly with either of these calls _DateToDayOfWeek and _DateToDayOfWeekISO

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
jchd

Both functions work but since the OP seemed to want the day longname as well in his code, it's preferable to use _DateToDayOfWeek  as it's Sunday-based just like _DateDayOfWeek. Of course if the goal is to decide if workday or not, then test for 6 or 7 is good enough.

  • Like 1

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
fmtdonnk

Hello

 

Thanks for the link

 

but still same question 

Local $iWeekday = _DateToDayOfWeekISO(@YEAR, @MON, @MDAY)
How I put a date as a variable instead of @year @mon @Mday

 

=========================

$sDate ="2018/05/22"

Local $iWeekday = _DateToDayOfWeekISO($sDate)

====================

 

Share this post


Link to post
Share on other sites
fmtdonnk

My question is how I can change into the function the date and put there a Variable that will increase by one into a loop

 

thanks

 

Share this post


Link to post
Share on other sites
jchd

Did you look at the code I supplied?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
fmtdonnk

HI JCHD

 

thank YOUUUUUUUU , No I didn't see your reply before. Now I tried it and its work perfectyl

 

I need to understand it, but before I do , I first thank you again

 

Have a very good evening

 

Franck

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

  • Similar Content

    • Pagi
      By Pagi
       
      <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>
      Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
    • mar3011
      By mar3011
      hello, I want to set in the inputbox field random key from the keyboard to which the function will be assigned, for example F4 function start notepad ALT + A function start notepad for one function. Thank you for any help.  
    • JuanFelipe
      By JuanFelipe
      Cambiar a español Hello friends, I need help with a problem I have, I want to know if there is any way to update a GUI already running, that is I have a GUI of a certain size and with a button I would like to enlarge it:
      example: $ form1 = GUICreate ("", 200,100,0,0)   When you press the button, the gui increases its size, and actuates the new size.
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
×