Jump to content

days of week for a date


Recommended Posts

  • Moderators

@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!

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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
 
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

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)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

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)

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

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

×
×
  • Create New...