Is there a way with MEL to get the system datestamp that looks something more like 200804040832, which would be 8:32 am on 04/04/2018? It doesn't have to be exactly like that, but I want something closer than what the DATETIMESTAMP() function provides.
Thank you,
Robin
There are several ways to do this, but if you want to strictly use MEL, you will most likely have to write a function using the ._TODAYSDATE and TIMESTAMP() functions. The process would be to convert the return values of those functions to a string and then parse out the values needed in order to construct a string in the format you desire. I could probably give you an example if someone else doesn't respond with a better idea. Another option would be to write a small command line script that could be called and return the current date/timestamp in the format you desire. Where exactly are you needing this functionality? Are you wanting to reference the function in a quicktext, form component, or both?
Thank you for the response. I can write the function to convert the date into a format that I want, I was just hoping that there was an easier way maybe using the runprocess() command. I am using the date and time as part of a unique identifier that wouldn't be duplicated.
Thank you, again,
Robin
You could use RUNTEXTPROCESS(progname, argStr) or RUNPROCESS() and reference a batch file that returns the date/timestamp in the format you desire:
Here is an example batch file that does just that:
@echo off
set datecode=%date:~-4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%%time:~6,2%
echo %datecode%
Just create you a batch file with the lines above and place it where you can reference it from your centricity clients (dependent upon your environment). You will have to play around with the specific versions of RUNPROCESS to figure out which is best for your environment. Check the help files for more guidance.
Thank you, again. While that would work for most people, because I am a consultant who writes forms for multiple clients, I don't often have the ability to save files onto the Citrix servers. I think I'm just going to have to format the datetimestamp() the way that I want it.
I do appreciate your help, though. Thank you.
Robin
Have you considered building the form component in HTML? That would make things a lot easier for you. 🙂
I use the following in MEL:
._TODAYSDATE+remove(TIMESTAMP(), match(TIMESTAMP()," "))
But you may have to tweak it to get what you want, because I believe that this leaves in the colons.
I would love to use HTML, but my client isn't using it yet. 🙁
Thank you. That's what I'll do.
Robin
Final thought. To do this in MEL, try the following in a function...
Note, if you want the time represented in military time, you will need to parse out the AM/PM identifier, convert the hour portion of the time string to a value and then add 12 to it if PM.
local datepart = sub(str(._TODAYSDATE),7,4) + sub(str(._TODAYSDATE),1,2) + sub(str(._TODAYSDATE),4,2)
local timepart = replacestr(str(TIMESTAMP()),":","")
local strTimeDateStamp
if (size(timepart)< 7) then
timepart = "0" + timepart
endif
strTimeDateStamp = datepart + sub(timepart, 1, 4)
Hi Robin,
I created a function you can use to get the date in the format you want:
{
fn getFormattedTime(){
local today = STR(._TODAYSDATE)
local time = TIMESTAMP()
local auxPM = ""
local auxAM = ""
RETURN SUB(today,7,4) + SUB(today,1,2) + SUB(today,4,2)
+ COND
CASE time == "12:00 PM"
"12"
CASE time == "12:00 AM"
"00"
CASE MATCH(time,1,"AM") > 0
auxAM = SUB(time,1,MATCH(time,1,":") - 1)
if SIZE(auxAM) == 2 then auxAM else "0" + auxAM endif
CASE MATCH(time,1,"PM") > 0
auxPM = STR(VAL(SUB(time,1,MATCH(time,1,":") - 1)) + 12)
if SIZE(auxPM) == 2 then auxPM else "0" + auxPM endif
ELSE ""
ENDCOND
+ STR(SUB(time,MATCH(time,1,":") + 1,2))
}
}
Best,
Tomas
Bummer!
I like it!