Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Month's abbreviated name to digits
#1
I wonder whether there exists a simple way to convert a date string with month as its abbreviated name to that with the month as digits. I have written a short QM function which it converts properly, however I a looking for a relevant system resource. Let me mention that the statement :

DateTime(x).fromstr(s) gives an error, unless month is used in "s" with its representation in digits. Many thanks in advance.
#2
Probably not. I know only 1 API, and it is used in FromStr.
#3
Thank you. I attach my solution, for any interest.

Function tempf03
Code:
Copy      Help
function# str'mon
;_i=tempf03("Apr")
;out _i
lpstr m="JanFebMarAprMayJunJulAugSepOctNovDec"
int i=find(m mon)
if(i<0)
,err "Error in month"
i=i/3+1
ret i
#4
C# is your friend so easy to parse dates 
i also had it output just the numeric month as another example 
Using c# dont need to break the date apart can process it all together and customize output
Function ParseDateExampleCs
Code:
Copy      Help
_s.timeformat("{dd-MMM-yy}" 0)
out _s
str code=
;using System;
;using System.Globalization;
;public class Example
;{
;,,public static string StaticFunc(string date)
;,,{
;,,,,DateTime parsedDate = DateTime.Parse(date);
;,,,,Console.WriteLine(parsedDate.ToString("MM"));
,,,,;return parsedDate.ToString("dd/MM/yy");
;,,}
;}
str R=CsFunc(code _s)
out R
for more info see
Standard Date and Time Format Strings

Parsing Date and Time Strings in .NET


Custom Date and Time Format Strings


Forum Jump:


Users browsing this thread: 1 Guest(s)