Reputation: 4406
I am using the Reporting feature in Visual Studio and I need to create a prop/variable to store the current date so I can display it on my form. I cannot seem to find the proper way to do this in the report view.
I originally tried a property of :
public DateTime CurrentDate {get;}
This did not work because there is no setter for it. To fix the problem I :
public DateTime CurrentDate{get{return DateTime.Now;}}
Thanks for the suggestions. They lead me in the right direction.
Upvotes: 0
Views: 2409
Reputation: 20374
For the Date
only, I would use
DateTime.Today
or
DateTime.Now.Date
Upvotes: 1
Reputation: 372
System.DateTime.Now. to get string format:
System.DateTime.Now.ToString()
Upvotes: 0
Reputation: 29000
You can try with this code
DateTime.Now
You can specify format
DateTime.Now.ToString("yourFormat")
Msdn : http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx
Upvotes: 1
Reputation: 2316
DateTime.Now
see: http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx
Upvotes: 6