473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Getting date in .NET

Baz
How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Thanks for any help!
Nov 16 '05 #1
4 3539
DateTime.Now.AddDays(-1)

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Baz" <Ba*@I-want-no-spam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Thanks for any help!

Nov 16 '05 #2
"Baz" <Ba*@I-want-no-spam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);


Use AddDays(-1)

-- Alan
Nov 16 '05 #3
Baz
Thanks a lot! I should be more attentive while reading documentation..

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:uS*************@TK2MSFTNGP12.phx.gbl...
DateTime.Now.AddDays(-1)

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Baz" <Ba*@I-want-no-spam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
How can I get yesterday's date in a program? I tried using the following, but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Thanks for any help!


Nov 16 '05 #4
Try

DateTime.Now.AddDays(-1)

"Baz" wrote:
How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Thanks for any help!

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ru | last post by:
Hello, I'm trying to parse a rss 1.0 docoment like the following example from http://www.instapundit.com: <?xml version="1.0" encoding="iso-8859-1" ?> - <rdf:RDF...
9
by: deko | last post by:
What is it with these dates? What are they so much trouble? All I want to do is subtract an hour, but not if that makes dtmTest less than dtmClt. Dim dtmStart As Date Dim dtmEnd As Date Dim...
36
by: Lindie | last post by:
The more I read the more confused I get. Too much on dates calulations in the groups. I need to know how often a book has been loaned out over the past year- 52 weeks. My table has Book...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.