venkat Posted April 7, 2009 Posted April 7, 2009 Hi, I have to send a date as input value to generate a report. If it is monday i have to give the input dates as friday's date to today's date. If it is other than monday i have to give the input values as previous date to today's date. I used the _now() function which gives the data in the format YYYY/MM/DD but I need the date in MM/DD/YY format. Also how to check for the monday conition. Thanks in Advance.
Moderators Melba23 Posted April 7, 2009 Moderators Posted April 7, 2009 venkat, I believe this does what you want:#Include <Date.au3> Global $iYear, $iMon, $iDay $iToday = _DateToDayValue(@YEAR, @MON, @MDAY) If @WDAY = 2 Then ; Today is Monday $iStart = $iToday - 3 Else ; Today is not Monday $iStart = $iToday - 1 EndIf _DayValueToDate($iStart, $iYear, $iMon, $iDay) $sRange = $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) & " - " _DayValueToDate($iToday, $iYear, $iMon, $iDay) $sRange &= $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) ConsoleWrite($sRange & @CRLF) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ChangMinYang Posted April 7, 2009 Posted April 7, 2009 Hi, I have to send a date as input value to generate a report. If it is monday i have to give the input dates as friday's date to today's date. If it is other than monday i have to give the input values as previous date to today's date. I used the _now() function which gives the data in the format YYYY/MM/DD but I need the date in MM/DD/YY format. Also how to check for the monday conition. Thanks in Advance. $pv_StrucA = DllStructCreate( "short Year;short Month;short Dow;short Day;short Hour;short Minute;short Second;short MSeconds" ) $av_dCallA = DllCall( $_DLL_PTR_Kernel32 , "int" , "GetLocalTime" , "ptr" , DllStructGetPtr( $pv_StrucA ) ) ;void WINAPI GetLocalTime( ; __out LPSYSTEMTIME lpSystemTime ; ); $av_TimeW[0] = DllStructGetData( $pv_StrucA , "Month" ) $av_TimeW[1] = DllStructGetData( $pv_StrucA , "Day" ) $av_TimeW[2] = DllStructGetData( $pv_StrucA , "Year" ) $av_TimeW[3] = DllStructGetData( $pv_StrucA , "Hour" ) $av_TimeW[4] = DllStructGetData( $pv_StrucA , "Minute" ) $av_TimeW[5] = DllStructGetData( $pv_StrucA , "Second" ) $av_TimeW[6] = DllStructGetData( $pv_StrucA , "MSeconds" ) $av_TimeW[7] = DllStructGetData( $pv_StrucA , "Dow" )
picaxe Posted April 7, 2009 Posted April 7, 2009 #include <Date.au3> ; todays date MM/DD/YY ConsoleWrite(@MON & "/" & @MDAY & "/" & stringright(@YEAR, 2) & @LF) ; yesterdays date MM/DD/YY ConsoleWrite(StringRegExpReplace(_DateAdd('D', -1, _NowCalcDate()), '\d{2}(\d{2})/(\d{2})/(\d{2})', '$2/$3/$1') & @LF) ; if today is monday then If @WDAY = 2 Then $yesterday = StringRegExpReplace(_DateAdd('D', -1, _NowCalcDate()), '\d{2}(\d{2})/(\d{2})/(\d{2})', '$2/$3/$1') ; some code EndIf
venkat Posted April 7, 2009 Author Posted April 7, 2009 Friend, I made a mistake when describing the format. Actually I need to give the input to an application. I have attached the image which tells how and where input is to be given. if monday friday's date(mm/dd/yy) 09:30 today's date(mm.dd/yy) 09:30 else previousdate(mm/dd/yy) 09:30 today's date(mm/dd/yy) 09:30 here the time remains constant. After send("!vc") filter window will open send ("{tab 5}"} where the cursor will be placed. I have to enter the value. For Example (today) 04/06/09 09:30 send tab will take to another box where i have to enter 04/07/09 09:30 Thanks in Advance venkat, I believe this does what you want:#Include <Date.au3> Global $iYear, $iMon, $iDay $iToday = _DateToDayValue(@YEAR, @MON, @MDAY) If @WDAY = 2 Then ; Today is Monday $iStart = $iToday - 3 Else ; Today is not Monday $iStart = $iToday - 1 EndIf _DayValueToDate($iStart, $iYear, $iMon, $iDay) $sRange = $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) & " - " _DayValueToDate($iToday, $iYear, $iMon, $iDay) $sRange &= $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) ConsoleWrite($sRange & @CRLF) M23
Moderators Melba23 Posted April 7, 2009 Moderators Posted April 7, 2009 venkat, Try this:#Include <Date.au3> Global $iYear, $iMon, $iDay $iToday = _DateToDayValue(@YEAR, @MON, @MDAY) If @WDAY = 2 Then ; Today is Monday $iStart = $iToday - 3 Else ; Today is not Monday $iStart = $iToday - 1 EndIf _DayValueToDate($iStart, $iYear, $iMon, $iDay) $sDate1 = $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) & " 09:30" _DayValueToDate($iToday, $iYear, $iMon, $iDay) $sDate2 = $iDay & "/" & $iMon & "/" & StringRight($iYear, 2) & " 09:30" ConsoleWrite($sDate1 & @CRLF) ConsoleWrite($sDate2 & @CRLF) So just send these 2 strings and you should be set. By the way, a slightly belated welcome to the AutoIt forums. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now