469,578 Members | 1,897 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Yesterdays date

Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.
Nov 19 '05 #1
8 2737
Have you tried:
DateTime.Now.AddDays(-1) ?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonmyous" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.

Nov 19 '05 #2
C#...

DateTime yesterday = DateTime.Now.AddDays(-1);

HTH
Dan
"Anonmyous" wrote:
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.

Nov 19 '05 #3
C#...

DateTime yesterday = DateTime.Now.AddDays(-1);

HTH
Dan
"Anonmyous" wrote:
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.

Nov 19 '05 #4
Try something like

System.DateTime.Now - TimeSpan.TicksPerDay

Eliyahu

"Anonmyous" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.

Nov 19 '05 #5
Ok, now I know about AddDays method. Thanks.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uy*************@TK2MSFTNGP15.phx.gbl...
Try something like

System.DateTime.Now - TimeSpan.TicksPerDay

Eliyahu

"Anonmyous" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.


Nov 19 '05 #6
Here's a complete example :

Yesterday.aspx
----------------
<script language="vb" runat="server">
Sub Page_Load()
Dim NextTime As Date = Now
NextTime = NextTime.AddDays(-1)
time.text = "Yesterday was " & NextTime
End Sub
</script>
<html>
<head><title>Yesterday</title></head>
<body>
<asp:label id="time" runat="server" /><br/>
</body>
</html>
-------------


Juan T. Llibre
ASP.NET MVP
===========
"Anonmyous" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.

Nov 19 '05 #7
btw, if you just want the date displayed
( and not the time ), use :

time.text = "Yesterday was " & Format(NextTime, "Short Date")
Juan T. Llibre
ASP.NET MVP
===========
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
Here's a complete example :

Yesterday.aspx
----------------
<script language="vb" runat="server">
Sub Page_Load()
Dim NextTime As Date = Now
NextTime = NextTime.AddDays(-1)
time.text = "Yesterday was " & NextTime
End Sub
</script>
<html>
<head><title>Yesterday</title></head>
<body>
<asp:label id="time" runat="server" /><br/>
</body>
</html>
-------------


Juan T. Llibre
ASP.NET MVP
===========
"Anonmyous" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.


Nov 19 '05 #8
How about this:

Dim ts As New TimeSpan(1, 0, 0, 0)
'Timespan(Days,Hours,Minutes,Seconds)
Dim t As Date = Date.Today.Subtract(ts)
time.text="Yesterday was " & t.ToShortDateString

Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by androtech | last post: by
4 posts views Thread by Richard Hollenbeck | last post: by
2 posts views Thread by Tjerk | last post: by
9 posts views Thread by Thomas R. Hummel | last post: by
6 posts views Thread by Mark | last post: by
1 post views Thread by VB Programmer | last post: by
12 posts views Thread by Assimalyst | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.