• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 737
  • Last Modified:


The following string deliver 12:00 with the appropriate date.   I need assistance with the code to deliver DateTime Now()

string htmlBody = "<font color=\"black\"><font face=\"arial\">Date: " + DateTime.Parse(Dates.Text)
1 Solution
With the parse method you can use the tostring method to format the field value any way you want... if you are sure it will always be a valid datetime value
BOEING39Author Commented:
What would the format look like in this example?
käµfm³d 👽Commented:
I think a clarification of what you mean by "I need assistance with the code to deliver DateTime Now()," but my first guess is that you are asking for something like:

string htmlBody = "<font color=\"black\"><font face=\"arial\">Date: " + DateTime.Now.Date.ToString();
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

BOEING39Author Commented:
I am have issues with two sections of this page.    

1.  Parameters:

cmd.Parameters.AddWithValue("@Dates", DateTime.Now.Date.ToString()Dates.Text);

2.  e-mail portion:

string htmlBody = "<font color=\"black\"><font face=\"arial\">Date: " + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")
Gustav BrockCIOCommented:
The first should probably read:

cmd.Parameters.AddWithValue("@Dates", DateTime.Now);

The second looks OK. What's the issue?

SAMIR BHOGAYTAFreelancer and IT ConsultantCommented:
hi.. this are the formats of date in c# try this

Specifier       Description                               Output
d               Short Date                               08/04/2007
D               Long Date                               08 April 2007
t               Short Time                               21:08
T               Long Time                               21:08:59
f               Full date and time                       08 April 2007 21:08
F               Full date and time (long)         08 April 2007 21:08:59
g               Default date and time                08/04/2007 21:08
G               Default date and time (long)       08/04/2007 21:08:59
M               Day / Month                                  08 April
r               RFC1123 date                                  Sun, 08 Apr 2007 21:08:59 GMT
s               Sortable date/time                         2007-04-08T21:08:59
u               Universal time, local timezone       2007-04-08 21:08:59Z
Y               Month / Year                                  April 2007
dd               Day                                                    08
ddd               Short Day Name                         Sun
dddd       Full Day Name                         Sunday
hh               2 digit hour                                  09
HH               2 digit hour (24 hour)                   21
mm               2 digit minute                                  08
MM               Month                                           04
MMM       Short Month name                         Apr
MMMM       Month name                                  April
ss               seconds                                           59
tt               AM/PM                                           PM
yy               2 digit year                                  07
yyyy       4 digit year                                  2007
:               seperator, e.g. {0:hh:mm:ss}          09:08:59
/               seperator, e.g. {0:dd/MM/yyyy}  08/04/2007
BOEING39Author Commented:
This resolved my question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now