fmtdonnk Posted May 30, 2018 Posted May 30, 2018 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
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
Moderators JLogan3o13 Posted May 30, 2018 Moderators Posted May 30, 2018 @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. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
jchd Posted May 30, 2018 Posted May 30, 2018 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 hereRegExp tutorial: enough to get startedPCRE 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)
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
jchd Posted May 30, 2018 Posted May 30, 2018 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 hereRegExp tutorial: enough to get startedPCRE 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)
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
jchd Posted May 30, 2018 Posted May 30, 2018 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 hereRegExp tutorial: enough to get startedPCRE 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)
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
jchd Posted May 30, 2018 Posted May 30, 2018 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 Earthshine 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 hereRegExp tutorial: enough to get startedPCRE 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)
Earthshine Posted May 30, 2018 Posted May 30, 2018 (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 May 30, 2018 by Earthshine My resources are limited. You must ask the right questions
jchd Posted May 30, 2018 Posted May 30, 2018 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. Earthshine 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 hereRegExp tutorial: enough to get startedPCRE 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)
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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) ====================
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
jchd Posted May 30, 2018 Posted May 30, 2018 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 hereRegExp tutorial: enough to get startedPCRE 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)
fmtdonnk Posted May 30, 2018 Author Posted May 30, 2018 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now