2 Replies - 433 Views - Last Post: 17 September 2012 - 02:33 AM Rate Topic: -----

#1 inkey  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 26-June 12

Date to string issue

Posted 17 September 2012 - 02:19 AM

Hi i am trying to get a date of -24 hours from todays date.

I have the following which gives me todays date to a string

string datetoday = DateTime.Now.ToString();


i know i can get yesterdays date by doing the following but i need it as a string.

DateTime date2 = DateTime.Today.AddDays(-1);


Any one know how to produce date-24 hours from todays date to string

Thanks Inkey

Is This A Good Question/Topic? 0
  • +

Replies To: Date to string issue

#2 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 312
  • View blog
  • Posts: 488
  • Joined: 13-June 12

Re: Date to string issue

Posted 17 September 2012 - 02:26 AM

*
POPULAR

Use ToString, like in the first example.

string yesterday = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");

Was This Post Helpful? 5
  • +
  • -

#3 inkey  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 26-June 12

Re: Date to string issue

Posted 17 September 2012 - 02:33 AM

View PostMrShoes, on 17 September 2012 - 02:26 AM, said:

Use ToString, like in the first example.

string yesterday = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");



Thanks very much that did the trick :smartass:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1