Yesterdays date

A

Anonmyous

Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.
 
J

Juan T. Llibre

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
===========
 
J

Juan T. Llibre

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
===========
 
C

Corey

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top