All about Dates and Days in IDEA !

4 posts / 0 new
Last post
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57
All about Dates and Days in IDEA !
Hello Group Members,
 
Equation building in IDEA is fun !
 
It is fun when we understand the purpose, area of applicability and syntax for each @Function.
 
We have caught ourselves using @Date() and @Day() quite regularly within the Equation Editor in IDEA.
 
Being very similar in appearance it is quite possible to interchange the two and have a moment of dismay.
 
@Date() is used to generate the System Date or Current Date.
 
@Day() on the other hand is used to generate the Date of any Date Field of your choice.
 
So if we run @Date() today it will return 16.10.2018 as a display or "20181016" in an IDEA date storage format.
 
On the other hand if you apply @Day("20181012") it will return 12.
 
So the former i.e. @Date() returns the System Date in a Date format while the latter i.e. @Day returns the Date as a number
 
While using them through a Field Manipulation - Data - Append, the Date field will be a Virtual Date and the Day field will be a Virtual Number.
 
Best Regards
 
Group Admin Team
Gerard Usher
Offline
Joined: 10/26/2018 - 08:40

I'm trying to join 2 databases using append and tag the system date on to the end of the filename.  The macro I'm using works fine, except my system date does not show leading zeros and I don't have the rights to change it.  This means that my filename is not showing the zeros and, e.g. instead of getting "filename_01032019.IMD" I get "filename132019 4.IMD" (the trailing 4 is the first digit from the time in "1/3/2019 4:58:05 AM" in my system date /time).  Does anybody have any suggestions on how to get the zeros and lose the space and first digit of the time when running the macro listed below?
Sub Main Call AppendDatabase() 'Filename_01.IMD Client.CloseDatabase "Append Databases.IMD" Client.CloseDatabase "Filename_02.IMD"End Sub
' File: Append DatabasesFunction AppendDatabase Set db = Client.OpenDatabase("Filename_01.IMD") sDate = Now()                sDate = iRemove(Left(sDate, 10), "/") Set task = db.AppendDatabase task.AddDatabase "Filename_02.IMD" dbName = "Filename " & "-" & sDate & ".IMD" task.PerformTask dbName, "" Set task = Nothing Set db = Nothing Client.OpenDatabase (dbName)End Function
 
If I replace sDate = Now() with sDate = DATE()
I get "filename132019.IMD". 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Gerard,

Try the following to get the date:

sDate = Now()
sDate = iReplace(iStr(Month(sDate), 2, 0) & iStr(Day(sDate),2, 0) & Year(sDate), " ", "0")
MsgBox sDate

I am using the Month, Day and Year function as the "/" might be different depending on the users computer.  This would fail on mine because I use the "-" instead of the "/", using these functions get around that.  I then use the iStr to change it to a string as these functions return an integer.  Finally I use the iReplace to change the space to a 0.

let me know if this solves your problem.

Brian

Gerard Usher
Offline
Joined: 10/26/2018 - 08:40

That worked! 
Thanks again for your prompt assistance.
Gerard