Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Picking data from ms sql with date field and

want it in this format ("dd MMM yyyy");.

txtRunDate.Text = DateTime.Now.Date.ToString("dd MMM yyyy");


table name :: trial   idno       variable(5)
                      date_trans datetime


how do i get the field date_trans using the format above


The example above is for the current date.


how do you code to get it using the field ' date_trans' in place of the 'Now'

txt_trans_Date= .......
Posted
Updated 18-Nov-14 7:03am
v6
Comments
PIEBALDconsult 18-Nov-14 12:25pm    
I strongly recommend you use an ISO 8601-compliant date format -- YYYY-MM-DD


And your question isn't clear, please use Improve question to add detail.
ZurdoDev 18-Nov-14 12:30pm    
I'm confused. You have the code to show it in the format you want. Where are you stuck?
Member 10744248 18-Nov-14 12:59pm    
how do you substitute the field date_trans in place of the 'Now' in the code syntax

Your question is a bit confusing; but do you mean the following:
C#
txtRunDate.Text = date_trans.Date.ToString("dd MMM yyyy");
 
Share this answer
 
Comments
Member 10744248 18-Nov-14 13:24pm    
yes
Maciej Los 18-Nov-14 16:32pm    
If it solves your issue, please mark this answer as a solution (green button).
Maciej Los 18-Nov-14 16:32pm    
5ed!
You can write
C#
CONVERT(varchar(20),date_trans,106)

in your select query. then you will get the date in the format "dd MMM yyyy"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900