Jump to content

Very easy question re: strings & dates


megatron
 Share

Recommended Posts

Hello guys, very simple problem I have:

I want to get a string consisting of the date like this: DD.MM.YYYY

I know the macros can give me a date inthe format DD/MM/YYYY but i need it delimited with . not /

I have also tried to make a string from the seporate @MON @YEAR etc macros, I think my understanding of syntax here is letting me down.

Any pointers would be much appreciated.

Link to comment
Share on other sites

  • Moderators

What ever is giving you this format: DD/MM/YYYY you could simply use StringReplace()

$sDateFunc = _MyDateFunctionGivingMeMyDateInformation();(You didn't state what you were using)
$sDateFunc = StringReplace($sDateFunc, '/', '.')
MsgBox(64, 'Presto', $sDateFunc)

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

  • Moderators

Smoke. thanks for your help. While you were typing I managed to solve the problem myself:

#Include <date.au3>

#include <Array.au3>

$avArray = _ArrayCreate(@MDAY, @MON, @YEAR)

Dim $Date = _ArrayToString( $avArray,".")

That's the really long way.... if you only have one date.

$sDate = @MDay & '.' & @MON & '.' & @YEAR
MsgBox(64, 'Info', $sDate)

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

One more question, if I may:

CODE
$sDate = @MDAY & '.' & @MON & '.' & @YEAR

; Shows the filenames of all files in the current directory

$search = FileFindFirstFile(*$sDate)

The part that is not working correctly is the FileFindFirstFile(*$sDate), no matter what I try I can't seem to get it to search for the date string with a wildcard prefixing it.

Link to comment
Share on other sites

  • Moderators

Did you try using the path to the directory as well?

There are functions also that could help you... _FileListToArray(), I've wrote a _FileListToArrayEx() option in the Examples forum, these return a list of all files in the Path+directory you choose, and you can loop through them to see if the files match with something like StringInStr().

You also may want to look at _PathSplit() so you can compare just the actual file name itself.

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

Did you try using the path to the directory as well?

There are functions also that could help you... _FileListToArray(), I've wrote a _FileListToArrayEx() option in the Examples forum, these return a list of all files in the Path+directory you choose, and you can loop through them to see if the files match with something like StringInStr().

You also may want to look at _PathSplit() so you can compare just the actual file name itself.

Following on from your advice it worked just great. Thanks so much dude!

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