Jump to content

Date


Recommended Posts

Hello.. I am trying the date function to create something for my script. Today is 5 Mar 2007.

#include <Date.au3>

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

$sNewDate = _DateAdd( 'd',1, _NowCalcDate())

Send($sNewDate)

What comes out in the notepad is 2007/03/06. But is there anyway i can make notepad that writes 6-Mar-2007??...please help me..i've tried to search for all fuctions in the command list le..thanks.. =)

Link to comment
Share on other sites

  • Moderators

$sString = '2007/03/06'
$aSplit = StringSplit($sString, '/')
$sOutput = $aSplit[3] & '-' & _GetMonth($aSplit[2]) & '-' & $aSplit[1]
MsgBox(0, '', $sOutput)

Func _GetMonth($nMonth)
    Local $aMonth = StringSplit('January,February,March,April,May,June,July,' & _
        'August,September,October,November,December', ',')
    Return $aMonth[$nMonth]
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

$sString = '2007/03/06'
$aSplit = StringSplit($sString, '/')
$sOutput = $aSplit[3] & '-' & _GetMonth($aSplit[2]) & '-' & $aSplit[1]
MsgBox(0, '', $sOutput)

Func _GetMonth($nMonth)
    Local $aMonth = StringSplit('January,February,March,April,May,June,July,' & _
        'August,September,October,November,December', ',')
    Return $aMonth[$nMonth]
EndFunc

Hi SmOke_N..Thanks for ur help!!.. The program u gave me was fantastic..but i need a program that goes with the computer's date. And i also need to like for example..if today the date is 5 Mar, i need the date that comes out in the MsgBox to be one day later than today..means 6 Mar. Could u help me more on this??.. sorry abt tat..need ur help on this..thanks.. =)

Link to comment
Share on other sites

  • Moderators

Hi SmOke_N..Thanks for ur help!!.. The program u gave me was fantastic..but i need a program that goes with the computer's date. And i also need to like for example..if today the date is 5 Mar, i need the date that comes out in the MsgBox to be one day later than today..means 6 Mar. Could u help me more on this??.. sorry abt tat..need ur help on this..thanks.. =)

So add 1 to it.

Edit:

I believe there is Add functions in the help file for dates aren't there?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

So add 1 to it.

Edit:

I believe there is Add functions in the help file for dates aren't there?

$sString = _DateAdd( 'd',1, _NowCalcDate())

$aSplit = StringSplit($sString, '/')

$sOutput = $aSplit[3] & '-' & _GetMonth($aSplit[2]) & '-' & $aSplit[1]

MsgBox(0, '', $sOutput)

Func _GetMonth($nMonth)

Local $aMonth = StringSplit('Jan,Feb,Mar,Apr,May,Jun,Jul,' & _

'Aug,Sep,Oct,Nov,Dec', ',')

Return $aMonth[$nMonth]

EndFunc

Is it something like tat??..i can't seem to work it out this way..sorrie..

Link to comment
Share on other sites

  • Moderators

Works fine for me when I add #include <date.au3>

#include <date.au3>
$sString = _DateAdd( 'd',1, _NowCalcDate())
$aSplit = StringSplit($sString, '/')
$sOutput = $aSplit[3] & '-' & _GetMonth($aSplit[2]) & '-' & $aSplit[1]
MsgBox(0, '', $sOutput)

Func _GetMonth($nMonth)
    Local $aMonth = StringSplit('January,February,March,April,May,June,July,' & _
        'August,September,October,November,December', ',')
    Return $aMonth[$nMonth]
EndFunc

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Works fine for me when I add #include <date.au3>

#include <date.au3>
$sString = _DateAdd( 'd',1, _NowCalcDate())
$aSplit = StringSplit($sString, '/')
$sOutput = $aSplit[3] & '-' & _GetMonth($aSplit[2]) & '-' & $aSplit[1]
MsgBox(0, '', $sOutput)

Func _GetMonth($nMonth)
    Local $aMonth = StringSplit('January,February,March,April,May,June,July,' & _
        'August,September,October,November,December', ',')
    Return $aMonth[$nMonth]
EndFunc

Oh..haha..sorrie..you are a pro in AutoIT man!!..haha..thanks..this has been realli a great help to me!!..cya =) cheers..

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...