472,352 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Yesterdays date

Hello,

how can I get the yesterdays date?

Thanks for any suggestions and tips.
Nov 19 '05 #1
8 2839
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does...
9
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very...
6
by: Mark | last post by:
Hi, Does anyone know where i can get some javscript code to work out yesterdays date Thanks Mark
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to...
1
by: VB Programmer | last post by:
How can I get yesterdays date? I would think now.date.subtract(1) works, but it doesn't. Thank.
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error...
5
code green
by: code green | last post by:
I need to do a query something like SELECT * FROM invoices WHERE date= 'yesterdays date'It is not as simple as one might think which means ideas I...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.