?
Solved

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

Posted on 2008-10-17
7
Medium Priority
?
2,637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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 1200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1200 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 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 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