c#


How to format a DateTime inside of List using WebApi Entity Framework


I have a Property
[DataType(DataType.Date)]
public DateTime? DatePost { get; set; }
And I want to format the DateTime for each item of this property.
Select(x => new
{
x.Price,
x.ItemsCount,
x.DatePost});
var result = query.toList();
So I was trying to use a foreach to get each property and change to ShortDateString, but the result of query it always come with the time together. The format has to be like this "dd/MM/yyyy".
List<dynamic> l = new List<dynamic>();
var result = users.ToList();
foreach (var item in result)
{
item.DatePost?.ToShortDateString();
l.Add(item);
}
return Ok(l);
The result is :
2017-04-15T23:53:00.193

Related Links

DataGridView: What is the best approach to handle Editable Data in DataGridView?
Export only grid view data on excel from page through C#
'Conversion failed' error is not captured while executing in C# or in stored procedure
c# async await and exception
Generic caching in c#
Parse - Resetting Passwords on ASP.NET MVC
Not all code paths return a value for boolean method in class
Unit of work and general repository package
Getting version number from a running proccess ( With NO access to the .exe path)
How do I pass selectlist that is string to controller to save as a int value in asp.net mvc 5
WPF binding/display of different units
Unity - ensure that only one instance does the given command
Entity Framework Migrations not creating tables on database publishing
JSON format C# not generating all quotes the serializer
UWP: how to customize the app title
Crystal report SetParameterValue

Categories

HOME
asterisk
stanford-nlp
alasql
jenkins-pipeline
okhttp3
azure-resource-manager
query-string
snmp
atlassian-fisheye
flowtype
google-api-oauth
yacc
oms
apache-httpclient-4.x
mamp
mbed
logstash-configuration
opendaylight
minimum
vivado-hls
cucumberjs
sonarlint
summernote
multipart
javaagents
gsuite
formtastic
launchd
typeclass
azure-table-storage
csproj
ipython-parallel
epub
maven-2
rtsp
file-descriptor
jvisualvm
pyexcel
jquery-ui-slider
autodesk-data-management
vpython
smooth-streaming
spring-ide
skype-bots
opticalflow
multi-targeting
cc
node.js-client
recursive-query
google-scholar
firebase-job-dispatcher
mac-app-store
universe
scriptengine
key-value-store
sprockets
patching
vitamio
paypal-subscriptions
android-progressbar
nugetgallery
ideavim
gitk
uinavigationitem
textblob
page-refresh
glog
genome
parseexception
firebase-tools
nexusdb
conkeror
chunks
touch-typing
teamstudio-unplugged
fedena
diffmerge
formbuilder
gnip
powerpoint-2010
parsefloat
indic
dotcmis
msdropdown
scjp
dateadd
jsmpp
vbaccelerator
grunt-wiredep
nsnumber
record-locking
maven-webstart-plugin
select2-rails
linqdatasource
tasklist
filedialog
github-archive
systrace
jqueryi-ui-buttonset
discussion-board
overlays
netbeans7.0
table-valued-parameters
tracd

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App