Remove seconds from Now()

# Thread: Remove seconds from Now()

1. Junior Member
Join Date
Dec 1969
Posts
4

## Remove seconds from Now()

Does anyone know of a way to remove the seconds from now() in ASP?<BR><BR>Thanks for any help !<BR>

2. Senior Member
Join Date
Dec 1969
Posts
6,476

## RE: Remove seconds from Now()

Use Date()<BR>;-)

3. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Remove seconds from Now()

The only way is to create a new string for it<BR><BR>Function NowNoSec<BR> NowNoSec = WeekDayName(WeekDay(Now()))& ", " & MonthName(Month(Now())) & " " & Day(Now()) & ", " & Year(Now()) & " " & (Hour(Now()) & ":" & Minute(Now())<BR>End Function<BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Why that does not work...

Suppose that NOW() happens to be #03/05/2005 3:07:42 PM#<BR><BR>Your function will return <BR> Saturday, May 3 2005 15:7<BR><BR>Suppose that NOW() happens to be #03/05/2005 3:07:42 AM#<BR><BR>Your function will return <BR> Saturday, May 3 2005 3:7<BR><BR>Neither of those hour/minute combos look especially attractive, do they?<BR><BR>Since one can get the DATE-ONLY in various ways--example <BR> FormatDateTime( Date(), vbLongDate ) <BR>--the only thing we really need to worry about is formatting the time.<BR><BR>So:<BR><BR>&#060;%<BR>Function TimeHHMM( tm ) <BR> Dim hr, ampm<BR> hr = Hour( tm )<BR> If hr &#062; 11 Then ampm = " PM" Else ampm = " AM"<BR> If hr = 0 Then hr = 12<BR> If hr &#062; 12 Then hr = hr - 12<BR> TimeHHMM = Right( "0" & hr, 2 ) & ":" & Right( "0" & Minute(tm), 2 ) & ampm<BR>End Function<BR>%&#062;<BR><BR>The other way to do this is via a regular expression:<BR><BR>&#060;%<BR>Function TimeHHMM( tm )<BR> Dim re, ts<BR> ts = FormatDateTime( tm, vbLongTime )<BR> Set re = New RegExp<BR> re.Pattern = ":dds"<BR> TimeHHMM = re.Replace( ts, "" )<BR>End Function<BR>%&#062;<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•