Solved

classic asp-DateAdd("h",4,now())

Posted on 2008-10-17
7
2,600 Views
Last Modified: 2012-05-05
i need to add 4 hours to the date and to print dd/mm/yyyy

help please
0
Comment
Question by:Sasha-N
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:nkoriginal
Comment Utility
Try this..

<%=dateadd("h", 1, now())%>

Let me know any question

0
 
LVL 5

Assisted Solution

by:nkoriginal
nkoriginal earned 200 total points
Comment Utility
For your case is

(here is with 4 hours more)

<%=dateadd("h", 4, now())%>
0
 
LVL 17

Assisted Solution

by:aflockhart
aflockhart earned 300 total points
Comment Utility
<%
sDate = Now()
sNewDate = DateAdd("h", 4, sDate)
response.write(FormatDateTime(sNewDate ,2))
 
  %>

Option "2" in the FormatDateTime function chooses your local "short time " format. As long as that is set to dd/mm/yyyy on the server, that's what you'll get.

Otherwise, this longer version should work:

<%
sDate = Now()
  sNewDate = DateAdd("m", 1, sDate)
  response.write(day(sNewDate) & "/" & month(sNewDate) & "/" & year(sNewDate))
 
 %>
 



0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:nkoriginal
Comment Utility
If you add this session

<%session.lcid=2057%>

you will see your date in DD/MM/YYYY

Here is en complete example


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
 

<%session.lcid=2057%>
 
 

<html>

<head>

<title>Test</title>

</head>
 

<body>
 

<%=dateadd("h", 1, now())%>
 

</body>

</html>

Open in new window

0
 

Author Comment

by:Sasha-N
Comment Utility
have you seen the title of my question?
0
 
LVL 17

Accepted Solution

by:
aflockhart earned 300 total points
Comment Utility
sorry, second version should also add hours ...

<%
sDate = Now()
  sNewDate = DateAdd("h", 4, sDate)
  response.write(day(sNewDate) & "/" & month(sNewDate) & "/" & year(sNewDate))
 
 %>
0
 
LVL 5

Assisted Solution

by:nkoriginal
nkoriginal earned 200 total points
Comment Utility
Do you try this

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
 
<%session.lcid=2057%>
 
 
<html>
<head>
<title>Test</title>
</head>
 
<body>
 
<%=dateadd("h", 1, now())%>
 
</body>
</html>
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now