Jump to content

PRINT CURRENT DAY - (Moved)


Go to solution Solved by Danp2,

Recommended Posts

 

Hello autoit companions, Could you help me with something basic that shows today, for example (Monday, Tuesday, Wednesday, etc) I have not interpreted the documentation correctly Thank you

I attach my code

 

 
Local  $sNewDate ,  $sLongDayName , $sCurrentDate
 
    $sCurrentDate = _NowCalcDate()  ; current date in format YYYY/MM/DD
    $sNewDate     = _DateAdd('d', 0, $sCurrentDate) ; current date + 2 days    
    $sLongDayName  =  _DateDayOfWeek ( $sNewDate,  2 )
    MsgBox ( 4096 ,  "" ,  "DAY IS : "  &   $sNewDate  &  " "  &  $sLongDayName )

 

but it shows me the date and not the day

Link to post
Share on other sites

You need to convert the date into the day of week before calling _DateDayOfWeek --

$sCurrentDate = _NowCalcDate()  ; current date in format YYYY/MM/DD
$sNewDate     = _DateAdd('d', 0, $sCurrentDate) ; current date + 2 days
$aYMD = StringSplit($sNewDate, "/", 2)
$iWeekday  =  _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2])
$sLongDayName  =  _DateDayOfWeek ( $iWeekday, $DMW_LOCALE_LONGNAME)
MsgBox ( 4096 ,  "" ,  "DAY IS : "  &   $sNewDate  &  " "  &  $sLongDayName)

 

Link to post
Share on other sites
  • Solution
#include <Date.au3>

Local  $sNewDate,  $sLongDayName, $sCurrentDate, $aYMD, $iWeekday

$sCurrentDate = _NowCalcDate()  ; current date in format YYYY/MM/DD
$sNewDate     = _DateAdd('d', 0, $sCurrentDate) ; current date + 2 days
$aYMD = StringSplit($sNewDate, "/", 2)
$iWeekday  =  _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2])
$sLongDayName  =  _DateDayOfWeek ( $iWeekday, $DMW_LOCALE_LONGNAME)
ConsoleWrite( "DAY IS : "  &   $sNewDate  &  " "  &  $sLongDayName & @CRLF)

The above runs fine for me with both 3.3.14.5 and 3.3.16.0 versions of Autoit. Can you run this exact code and then post the Scite output panel results?

FYI, they should look like this if you are running the full version of Scite --

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\danpo\Downloads\test.au3" /UserParams    
+>16:08:47 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\danpo\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\danpo\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\danpo\Downloads\test.au3
+>16:08:47 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\danpo\Downloads\test.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
DAY IS : 2022/04/27 Wednesday
+>16:08:47 AutoIt3.exe ended.rc:0
+>16:08:47 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.9807

 

Link to post
Share on other sites
33 minutes ago, stiv said:

What version do you have?

Runs fine for me with AutoIt 3.3.14.0

#include <Date.au3>
$sCurrentDate = _NowCalcDate()  ; current date in format YYYY/MM/DD
$aYMD = StringSplit($sCurrentDate, "/", 2)
$iWeekday  =  _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2])
$sLongDayName  =  _DateDayOfWeek ( $iWeekday, $DMW_LOCALE_LONGNAME)
MsgBox ( 4096 ,  "" ,  "DAY IS : "  &   $sCurrentDate  &  " "  &  $sLongDayName)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...