Jump to content

Calender


Recommended Posts

What am I doing wrong or missing that the calender will not give me the short date mm/dd/yy?

Thanks in advance for your time.

=====================================================================

#include <GUIConstants.au3>

$Dun = GUICreate("DUNNING SELECT", 329, 445, 201, 139)

$Button1 = GUICtrlCreateButton("OK", 120, 400, 89, 33)

GUICtrlSetState($Button1, $GUI_DEFBUTTON)

$Group1 = GUICtrlCreateGroup("SELECT A ACTION DATE TO VIEW ACCOUNT AGAIN", 16, 128, 297, 193)

$Action = GUICtrlCreateMonthCal("", 32, 144, 257, 161, $DTS_SHORTDATEFORMAT)

GUICtrlSetState(-1, $GUI_ACCEPTFILES)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState()

$Group2 = GUICtrlCreateGroup("TOTAL DOLLAR AMOUNT PAST DUE", 16, 16, 297, 49)

$Dollar = GUICtrlCreateInput("", 24, 32, 281, 21, -1, $WS_EX_CLIENTEDGE)

GUICtrlSetState(-1, $GUI_ACCEPTFILES)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group3 = GUICtrlCreateGroup("SELECT DUNNING LETTER TYPE", 16, 72, 297, 49)

$Dun = GUICtrlCreateCombo("DUN-1", 24, 88, 281, 21)

GUICtrlSetData(-1, "DUN-2|DUN-3|DUN-4|DUN-PRESUSP|DUN-SUSP|DUN-PREDMND", "")

GUICtrlSetState(-1, $GUI_ACCEPTFILES)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group4 = GUICtrlCreateGroup("ADD ADDITIONAL COMMENT IF DESIRED", 16, 336, 297, 49)

$Add = GUICtrlCreateInput("", 24, 352, 281, 21, -1, $WS_EX_CLIENTEDGE)

GUICtrlSetState(-1, $GUI_ACCEPTFILES)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $Button1

ExitLoop

EndSelect

WEnd

MsgBox(4096, "", GUICtrlread($Action))

Exit

Link to comment
Share on other sites

i know theres other ways but quick way i made was a qucik and simple stringsplit

#include <GUIConstants.au3>

$Dun = GUICreate("DUNNING SELECT", 329, 445, 201, 139)

$Button1 = GUICtrlCreateButton("OK", 120, 400, 89, 33)
GUICtrlSetState($Button1, $GUI_DEFBUTTON)

$Group1 = GUICtrlCreateGroup("SELECT A ACTION DATE TO VIEW ACCOUNT AGAIN", 16, 128, 297, 193)
$Action = GUICtrlCreateMonthCal("", 32, 144, 257, 161, $DTS_SHORTDATEFORMAT)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()

$Group2 = GUICtrlCreateGroup("TOTAL DOLLAR AMOUNT PAST DUE", 16, 16, 297, 49)
$Dollar = GUICtrlCreateInput("", 24, 32, 281, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group3 = GUICtrlCreateGroup("SELECT DUNNING LETTER TYPE", 16, 72, 297, 49)
$Dun = GUICtrlCreateCombo("DUN-1", 24, 88, 281, 21)
GUICtrlSetData(-1, "DUN-2|DUN-3|DUN-4|DUN-PRESUSP|DUN-SUSP|DUN-PREDMND", "")
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group4 = GUICtrlCreateGroup("ADD ADDITIONAL COMMENT IF DESIRED", 16, 336, 297, 49)
$Add = GUICtrlCreateInput("", 24, 352, 281, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $Button1
ExitLoop
EndSelect
WEnd

$date = StringSplit(GUICtrlread($Action),"/")
Msgbox(0,"Date",$date[2] & "/" & $date[3] & "/" & $date[1])

Exit
Link to comment
Share on other sites

Thank you very much for responding. The only question I have is how do I make the year show as 06 instead of 2006. I only have a cell to fill that allows only 06

Thanks

Thanks again thatsgreat234. Works perfect...

Edited by RickOShay
Link to comment
Share on other sites

once again i know theres a better way but im WAY to lazy :) just did a string trim left removes the first 2 characters

#include <GUIConstants.au3>

$Dun = GUICreate("DUNNING SELECT", 329, 445, 201, 139)

$Button1 = GUICtrlCreateButton("OK", 120, 400, 89, 33)
GUICtrlSetState($Button1, $GUI_DEFBUTTON)

$Group1 = GUICtrlCreateGroup("SELECT A ACTION DATE TO VIEW ACCOUNT AGAIN", 16, 128, 297, 193)
$Action = GUICtrlCreateMonthCal("", 32, 144, 257, 161, $DTS_SHORTDATEFORMAT)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()

$Group2 = GUICtrlCreateGroup("TOTAL DOLLAR AMOUNT PAST DUE", 16, 16, 297, 49)
$Dollar = GUICtrlCreateInput("", 24, 32, 281, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group3 = GUICtrlCreateGroup("SELECT DUNNING LETTER TYPE", 16, 72, 297, 49)
$Dun = GUICtrlCreateCombo("DUN-1", 24, 88, 281, 21)
GUICtrlSetData(-1, "DUN-2|DUN-3|DUN-4|DUN-PRESUSP|DUN-SUSP|DUN-PREDMND", "")
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group4 = GUICtrlCreateGroup("ADD ADDITIONAL COMMENT IF DESIRED", 16, 336, 297, 49)
$Add = GUICtrlCreateInput("", 24, 352, 281, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $Button1
ExitLoop
EndSelect
WEnd

$date = StringSplit(GUICtrlread($Action),"/")
Msgbox(0,"Date",$date[2] & "/" & $date[3] & "/" & StringTrimLeft($date[1],2))

Exit
Link to comment
Share on other sites

Thanks again thatsgreat2345.

I have one final question. Since I could not get the $DTS_SHORTDATEFORMAT to work with the calander. Is it only allowed with the guictrlcreatedate function?

Edited by RickOShay
Link to comment
Share on other sites

Try this I wrote this a while back, just include it at the top of your program.

Like this

#include <Date_jsb.au3>

This is the code inside Date_jsb.au3

#include-once

; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:    English
; Description:  Function(s) that assist with date string management.
;
; Version 1.0.0 - Jan. 12, 2006
;
; -------- History ---------------
; January 12, 2006 - creation
; ------------------------------------------------------------------------------

opt("MustDeclareVars", 0)                                           ;0=no, 1=require pre-declare

;===============================================================================
;
; Function Name:    _DateLongToShort()
; Description:    Converts a long format date string to a "mm/dd/yyyy" string
; Syntax:          _DateLongToShort($sLongDate)
;
; Parameter(s):  $s_LongDate         = The long format date to convert (ie. "Monday, January 09, 2006")
;                  $f_Format (optional)= 0 for mm/dd/yyyy
;                                      = 1 for yyyyy/mm/dd
; Requirement(s):   None
; Return Value(s):   On Success - date string in mm/dd/yyyy or yyyy/mm/dd form
;                   On Failure - Returns an empty string "" if $s_LongDate is not a string
;                       @Error=1 $s_LongDate is not a valid long format date string
; Author(s):        JackB
; Note(s):
;===============================================================================
Func _DateLongToShort($s_LongDate, $f_Format = 0)
  Local $M, $D, $Y
  Local $a_tmpstr
  Local $i_Len
  
  If Not IsString($s_LongDate) Then
    SetError(1)
    Return -1
  Else
    $a_tmpstr = StringSplit($s_LongDate, ",")
    If $a_tmpstr[0] > 0 Then
      Select
        Case $a_tmpstr[1] == "Sunday"
        Case $a_tmpstr[1] == "Monday"
        Case $a_tmpstr[1] == "Tuesday"
        Case $a_tmpstr[1] == "Wednesday"
        Case $a_tmpstr[1] == "Thursday"
        Case $a_tmpstr[1] == "Friday"
        Case $a_tmpstr[1] == "Saturday"
        Case Else
          SetError(1)
          Return -1
      EndSelect
    Else
      SetError(1)
      Return -1
    EndIf
    $a_tmpstr[2] = StringStripWS($a_tmpstr[2], 3)
    $i_Len = StringLen($a_tmpstr[2])
    $M = StringLeft($a_tmpstr[2], $i_Len - 3)
    $D = StringRight($a_tmpstr[2], 2)
    Select
      Case $M == "January"
        $M = "1"
      Case $M == "February"
        $M = "2"
      Case $M == "March"
        $M = "3"
      Case $M == "April"
        $M = "4"
      Case $M == "May"
        $M = "5"
      Case $M == "June"
        $M = "6"
      Case $M == "July"
        $M = "7"
      Case $M == "August"
        $M = "8"
      Case $M == "September"
        $M = "9"
      Case $M == "October"
        $M = "10"
      Case $M == "November"
        $M = "11"
      Case $M == "December"
        $M = "12"
      Case Else
        SetError(1)
        Return -1
    EndSelect
  EndIf
  $Y = StringStripWS($a_tmpstr[3], 3)
  SetError(0)
  If $f_Format = 1 Then
    If Number($M) < 10 Then $M = "0" & $M
    Return $Y & "/" & $M & "/" & $D
  Else
    Return $M & "/" & $D & "/" & $Y
  EndIf
  
EndFunc  ;==>_DateLongToShort
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...