Jump to content

Return calendar selected date as yday


Recommended Posts

Hello all, I am curious if there is a way to convert the output of the calendar to the day of the year. I have looked all over the forums and haven't really found what I was looking for.

Where

$Date = GUICtrlCreateMonthCal(@year & "/" & @mon & "/" & @mday , 10, 10)
GuiCtrlSetOnEvent ($Date, "Date")

would be my calendar, when I click the day, I am trying to get it to give me the yday instead of the full date.

Func Date()
    MsgBox (4096, "Date", "The Date you have selected is "& GuiCtrlRead ($date))
;instead of $date being output, I would like it's respective "yday"
EndFunc

I have found the way to calculate this from the beginning of a year but how do I extract the year from the date selected to do this calculation? Any help would be greatly appreciated :huh2: I am sure I am missing something really simple...

Thanks!

Edited by Jkeith247
Link to comment
Share on other sites

If you are looking to just do this with the current day, then the macro @YDAY gives the current day of the year.

If you are looking to calculate the day of the year from another date, then look at the Date Management section of the User Defined Functions in the help :huh2:

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <Date.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Date, $msg, $ok_B
    GUICreate("Get date", 210, 210)

    $Date = GUICtrlCreateMonthCal(@year & "/" & @mon & "/" & @mday, 10, 10)
    $ok_B = GuiCtrlCreateButton ('OK', 10, 180, 100)
    GUISetState()

    ; Run the GUI until the dialog is closed or timeout

    Do
        $msg = GUIGetMsg()
        If $msg = $ok_B Then MsgBox(0, 'Text',  1 + (_DateDiff('d', StringLeft(GUICtrlRead($Date), 4) & "/01/01 00:00:00", GUICtrlRead($Date))) & @CRLF & 'YDAY is : ' & @YDAY, 2)
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Glad, that I could help! :huh2:

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...