Sign in to follow this  
Followers 0
megatron

Very easy question re: strings & dates

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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,".")

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

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

:whistle:

I love you! :) thx

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

/bump

Share this post


Link to post
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.


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.

Share this post


Link to post
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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0