Solved

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

Posted on 2008-10-17
7
2,612 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

790 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