Jump to content

date manipulation


Go to solution Solved by Nine,

Recommended Posts

I need to print out dates in a specfic format YYYY-MM-DD   

I can get it to work for the first time but since i am using  _dateAdd function it converts my date to YYYY/MM/DD

Any ideas on what im missing to convert it to the - instead of the / when outputting the data?

 

 

$Date_FY_YearStart = GUICtrlCreateDate("2022-01-01", 23, 96, 134, 105)
Local $sStyle = "yyyy-mm-dd"
GUICtrlSendMsg($Date_FY_YearStart, $DTM_SETFORMATW, 0, $sStyle)

$currentFYWeekDate = $FYStart
$currentFYweekDTEnd = _DateAdd('D', 6, $FYStart)



Send("<start dtype=" & "{ASC 34}" & "Date" & "{ASC 34}" & ">" & $currentFYWeekDate & "</start>"& @CR)

Thanks in advance for any help.

Link to comment
Share on other sites

  • Solution

Maybe this :

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

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("2022/01/01", 10, 10, 185, 20)

    ; to select a specific default format
    Local $sStyle = "yyyy-MM-dd"
    GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Selected", GUICtrlRead($idDate))

    Local $currentFYWeekDate = StringReplace(GUICtrlRead($idDate), "-", "/")
    Local $currentFYweekDTEnd = _DateAdd('D', 6, $currentFYWeekDate)

    ConsoleWrite(StringReplace($currentFYweekDTEnd, "/", "-") & @CRLF)
EndFunc   ;==>Example

 

Link to comment
Share on other sites

Forgot about stringreplace function it worked perfectly i just added that to my output stream.

 

Send("<start dtype=" & "{ASC 34}" & "Date" & "{ASC 34}" & ">" & StringReplace($currentFYWeekDate,"/","-") & "</start>"& @CR)
Send("<end dtype=" & "{ASC 34}" & "Date" & "{ASC 34}" & ">" & StringReplace($currentFYweekDTEnd,"/","-") & "</end>"& @CR)

Thanks for the help 🙂

Edited by goodmanjl531
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...