Add Number to variable 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
 
J

Jacob Skaria

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
 
B

bijan

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
 
J

Jacob Skaria

You can convert varDate1 to date and then add..

CDate(varDate1) + 180

If this post helps click Yes
 
D

Doug Robbins - Word MVP on news.microsoft.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

date varable 5
How to add day to PWA 2016 date format? 0
International Date formatting 6
Date Format - simple question 1
Combobox date value matching 0
Dates Challenge 0
VB Date Format 8
ComboBox value matching 0

Top