|
-
May 20th, 2011, 10:40 PM
#1
Thread Starter
Lively Member
[RESOLVED] DateAdd Without Seconds
Hi. I'm trying to compare 2 dates to see if they match up (e.g. 1/05/2011 and 1/05/2011) but I'm doing something wrong. So my question is, how do I get rid of the seconds in the code below?
Code:
y = DateAdd("d", -daypas + x, Now)
This creates #2011-05-01 13:22:40# but I want it to be #2011-05-01#
Formating it (d/mm/yyyy) creates a string (when I store it in a text file) and when I do this even though the two dates look the same (the other date is created by a calendar control) VB doesn't see a match. So any ideas? Thanks.
-
May 20th, 2011, 11:22 PM
#2
Re: DateAdd Without Seconds
You could just 'extract' the dd/mm/yyyy component of Now
Code:
y = DateAdd("d", -daypas + x, Cdate(Format(Now, "dd/mm/yyyy")))
-
May 20th, 2011, 11:43 PM
#3
Thread Starter
Lively Member
Re: DateAdd Without Seconds
That works perfectly. Nice work Doogle.
-
May 21st, 2011, 01:15 AM
#4
Re: [RESOLVED] DateAdd Without Seconds
Why use Now then to struggle to remove the Time?
If you want only the date without time,use Date() function instead of Now().
Now = Date + Time
Code:
y = DateAdd("d", -daypas + x, Date)
-
May 21st, 2011, 04:29 AM
#5
Thread Starter
Lively Member
Re: [RESOLVED] DateAdd Without Seconds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|