Solved

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

Posted on 2008-10-17
7
2,603 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
ID: 22741181
Try this..

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

Let me know any question

0
 
LVL 5

Assisted Solution

by:nkoriginal
nkoriginal earned 200 total points
ID: 22741191
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
ID: 22741255
<%
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:nkoriginal
ID: 22741258
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
ID: 22741262
have you seen the title of my question?
0
 
LVL 17

Accepted Solution

by:
aflockhart earned 300 total points
ID: 22741270
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
ID: 22741414
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

937 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

7 Experts available now in Live!

Get 1:1 Help Now