Add Number to variable date

  • Thread starter Thread starter bijan
  • Start date Start date
B

bijan

Hi Experts,
I have a variable for date that calls in SQL for cut of time :
Vardate1= Format(Me.TextBox1.Value, "DD MMM YYYY")
:
:
" AND (Table1.DATE_SCH>='" & Vardate1 & "'" & _
What I need is how add 180 days to this cut of time automatically, I tried :
AND (Table1.DATE_SCH>='" & Vardate1 & "' + 180" & _
But I didn't get proper date,
Thanks in advance for any help
Bijan
 
Dear Bijan

Try the below code and make sure you have declared the variable varDate1 as
Date

'" & Vardate1 + 180 & "'

If this post helps click Yes
 
Hi Jacob,
I tried your code and get type mismatch error, It seems property of vardate1
isn't date and as I mentioned It set to:
vardate1 = Format(Me.TextBox1.Value, "DD MMM YYYY")
Bijan
 
You can convert varDate1 to date and then add..

CDate(varDate1) + 180

If this post helps click Yes
 
Use the DateAdd function

Vardate1 = Format(DateAdd("d", 180, Me.TextBox1.Value), "dd MMM yyyy")
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
Back
Top