[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.
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")))
Re: DateAdd Without Seconds
That works perfectly. Nice work Doogle.
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)
Re: [RESOLVED] DateAdd Without Seconds