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!

How to get your question answered on this forum!

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

    • SharpDressedMan
      By SharpDressedMan
      I have an array of subarrays, eg:
      local $a[3] = [ 1, 2, 3 ] local $b[3] = [ 4, 5, 6 ] local $c[2] = [ $a, $b ] I can read read a subarray element of the array, as follows:
      local $c12 = ($c[1])[2] ; result: $c12 = 6 However, when I try to set a subarray element as follows, it fails:
      ($c[1])[2] = 12 ; this fails to set subarray element local $c12 = ($c[1])[2] ; result: $c12 = 6 How to set a subarray element ?
      Thanks
    • nooneclose
      By nooneclose
      Good morning everyone, I thought I had already solved this issue but it turns out I did not. 
      My code finds unread emails with this specific subject line of "request" but when I change the subject to SKIPPED + "request" = ("SKIPPED request") the program still finds the email and tries to process it. I only want to process emails with the exact match subject of "request".
      Here is my code that "finds" the unread emails with the subject of "request" or so I thought. 
      Func ListUnreadEmails() ;******************************************************************************* ; Lists all unread E-mails from the folder Outlook-UDF-Test ;******************************************************************************* ; Stores all the unRead emails into an array Global $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, _ "[UnRead]=True", "Subject", "request", "EntryID,Subject", "", 1) ; Displays the array of unRead emails If IsArray($aItems) Then ;_ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Unread mails") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", _ "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf ; Gets the number of unread emails Global $numberOfUnRead = UBound($aItems, $UBOUND_ROWS) - 1 ;MsgBox("", "Number of Unread emails", $numberOfUnRead) EndFunc It acts as if any part of the subject containing the word "request" and the email is unread that it will try to process it. (I think)
    • KhalidAnsari
      By KhalidAnsari
      Hi,
      I need to automate Java application using AutoIt, I have refer forum for the same, as per forum I am using Java Access Bridge to finding control name. But could not set value to control. Below is my sample code 
      Send("#r")
      sleep(1500)
      Send("D:\javaapplication\javaapplication\Hello.jar{Enter}")
      WinActivate("Penjumlahan")
      sleep(1500)
      ControlSetText("Penjumlahan", "", "Name:  A :", "demo")
      Java Application and Java Ferret screen

    • QaisBsharat
      By QaisBsharat
      Hello, 
      May i know how can i automation qt application?
      Using controlclick not mouse and positions
       
      Thanks
    • nooneclose
      By nooneclose
      Good afternoon, I am in need of some help. I am sure this is a stupid question requiring only one or two lines of code. However, I would greatly appreciate the help I cannot figure this out. I also tried searching for the answer on the internet but no one except me apparently seems to be having a hard time figuring this out and or is asking about it. 
      I simply want to change the "status" of an email from unread to read once I have processed it. My code is over 500 lines and I would like not to clutter this post with it. Assume I have all my includes and connections properly defined and stuff. 
      Here is the bit of code where I am trying to change the email that was used from unread to read:
      Func ChangeEmailStatus() ;******************************************************************************* ; changes the status of an email from unread to Read ;******************************************************************************* Local $iRows = UBound($aItems, $UBOUND_ROWS) MsgBox("", "Number of Unread emails (Before Change)", $iRows) _OL_ItemModify($oOutlook,$aItems[$i][0], Default, "Read=True") MsgBox("", "Array Display 1", $aItems[1][0]) MsgBox("", "Array Display 2", $aItems[2][0]) Local $iRows = UBound($aItems, $UBOUND_ROWS) MsgBox("", "Number of Unread emails (After Change)", $iRows) EndFunc  
×