Hello, Are there any DXL functions to give i.e. return day of month as DD (01, 02 ... 31), Day of week as XXX (Mon, Tue etc), month as MM or XXX (Jan, Feb etc) and year as YYYY hour as 00 to 24 as DD minute as 00 to 59 that corresponds to today's date and current time please? Thanks and best regards, Mike
MikeMelon - Fri Nov 21 16:45:49 EST 2014 |
Re: Today's Month Year Day Date as String
print stringOf( (dateAndTime today(), "dd.MM.yyyy") ) // 22.11.2014 at time of post ...
print stringOf( (dateOnly today()), "dd" ) "\n" // 22
print stringOf( (dateOnly today()), "MM" ) "\n" // 11
print stringOf( (dateOnly today()), "MMM" ) "\n" // Nov
print stringOf( (dateOnly today()), "MMMM yy" ) "\n" // November 14
// You should also use this when converting strings to dates ...
print stringOf( date("11 12 13", "yy MM dd"), "dd.MMMM.yyyy") "\n"
// --> 13.Dezember.2011
// You can also use locales ...
// translate from german locale to english
print stringOf (date("01 Dezember 14", locale 1031, "dd MMMM yy"), locale 1033, "MMMM")
// prints December ...
Hope this helps, regards, Mathias |
Re: Today's Month Year Day Date as String Mathias Mamsch - Sat Nov 22 14:31:29 EST 2014
print stringOf( (dateAndTime today(), "dd.MM.yyyy") ) // 22.11.2014 at time of post ...
print stringOf( (dateOnly today()), "dd" ) "\n" // 22
print stringOf( (dateOnly today()), "MM" ) "\n" // 11
print stringOf( (dateOnly today()), "MMM" ) "\n" // Nov
print stringOf( (dateOnly today()), "MMMM yy" ) "\n" // November 14
// You should also use this when converting strings to dates ...
print stringOf( date("11 12 13", "yy MM dd"), "dd.MMMM.yyyy") "\n"
// --> 13.Dezember.2011
// You can also use locales ...
// translate from german locale to english
print stringOf (date("01 Dezember 14", locale 1031, "dd MMMM yy"), locale 1033, "MMMM")
// prints December ...
Hope this helps, regards, Mathias Hi Mathias, Thanks a bunch for the simple expressions to extract dd, month and year. Is there a way extract hour, minute and seconds as two digit number strings please? Or do I have to write string extract functions of my own to get the time segments? Thanks again for the help. Best regards, Mike
|
Re: Today's Month Year Day Date as String MikeMelon - Mon Nov 24 09:54:02 EST 2014 Hi Mathias, Thanks a bunch for the simple expressions to extract dd, month and year. Is there a way extract hour, minute and seconds as two digit number strings please? Or do I have to write string extract functions of my own to get the time segments? Thanks again for the help. Best regards, Mike
I wrote the following code to extract time:
string now_date_time
now_date_time = stringOf((dateAndTime today(), "dd.MM.yyyy"))
print now_date_time "\n"
Above code gave following output time results 24.11.2014 10:18:25 10:18:25 10
|
Re: Today's Month Year Day Date as String Hi, I would continue this post with Date / String and Int types. I try to sort some history object by date and the only way I could is by concatenating some int with string types. I have, Date ddate, int idate, string sdate. Well I catch my date in a date format (ddate) but there is no way to display it as (YY/MM/DD) in order to sort it. So I do idate = intOf(ddate) in order to sort it. But sort function is ok just with string types, so I do sdate = idate"" How can I retrieve my string sdate (which is a false int) into a true Date ? (almost last line : for (i=0; i<count; i++) print dates[i] "\n")
Here is my code :
|
Re: Today's Month Year Day Date as String Estebell - Tue Dec 09 09:36:32 EST 2014 Hi, I would continue this post with Date / String and Int types. I try to sort some history object by date and the only way I could is by concatenating some int with string types. I have, Date ddate, int idate, string sdate. Well I catch my date in a date format (ddate) but there is no way to display it as (YY/MM/DD) in order to sort it. So I do idate = intOf(ddate) in order to sort it. But sort function is ok just with string types, so I do sdate = idate"" How can I retrieve my string sdate (which is a false int) into a true Date ? (almost last line : for (i=0; i<count; i++) print dates[i] "\n")
Here is my code :
I don't get it ... Of course you can create any string representation of a date ... Try: Date d = today() print stringOf (d, "yyyy/MM/dd") The other thing you can do is, let the skip list do the sorting for you... Just put your Dates in a skip list and use the intOf(Date) as a key. The skip will sort your dates (or your history entries, or whatever you put into it with those keys) and to go over them you just need to iterate over the skip. Regards, Mathias |
Re: Today's Month Year Day Date as String Estebell - Tue Dec 09 09:36:32 EST 2014 Hi, I would continue this post with Date / String and Int types. I try to sort some history object by date and the only way I could is by concatenating some int with string types. I have, Date ddate, int idate, string sdate. Well I catch my date in a date format (ddate) but there is no way to display it as (YY/MM/DD) in order to sort it. So I do idate = intOf(ddate) in order to sort it. But sort function is ok just with string types, so I do sdate = idate"" How can I retrieve my string sdate (which is a false int) into a true Date ? (almost last line : for (i=0; i<count; i++) print dates[i] "\n")
Here is my code :
OK this is a good thing. Now, I want to have dates of history changes about one HystoryType only. So I add in the second loop :
string ChampDateEditePar ()
{
Object o
Module theMidule = current
int count = 0
for o in all theModule do{
History h
for h in o do {
count++
}
}
string dates[count]
int i = 0
for o in all theModule do{
History h
for h in o do {
HistoryType ht = h.type
Date date1 = dateOnly(h.date)
string date2 = stringOf (date1, "yyyy/MM/dd")
if (ht == modifyObject)
{
dates[i++] = date2
}
}
}
sort dates
for (i=0; i<count; i++) print dates[i] "\n"
return dates[0]
}
But when there is no history for an object, then count = 0 and dates[i] is out of limits. How can I avoid this error ? |