Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Format in String Builder
Message
From
03/06/2014 11:20:10
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01601157
Message ID:
01601201
Views:
38
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi everybody,
>>>
>>>I am trying to translate the following VFP code to C#
>>>
>>>
>>>                        padr(substr(transform(date_time),1,len(transform(date_time))-3),20)+' '+;
>>>
>>>This is what I wrote so far and a bit confused about date format and getting rid of AM/PM part:
>>>
>>>
>>>
>>> sbResult.AppendFormat("{0,20}", row.Field<DateTime?>("date_time"));
>>>
>>>I am not sure how to specify that g format for the date time and how to get rid of AM/PM designator (as VFP code seems to be doing).
>>>
>>>Thanks in advance.
>>
>>Amazing thing Google, if you think to try it........ http://www.dotnetperls.com/datetime-format
>
>So, is it:
>
>
>sbResult.AppendFormat("{0,20}", row.Field<DateTime?>("date_time").ToString("G"));
>
>But how to get rid of last AM/PM (BTW, not sure why VFP is removing it as the time will be ambiguous). Same thing of getting rid of last 3 chars?

Think if you change the format G and specify 24 hour format, it should not be a problem
Console.WriteLine("{0,20:MM/dd/yyyy HH:mm:ss}", DateTime.Now);
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform