PC Review


Reply
Thread Tools Rate Thread

Add Number to variable date

 
 
bijan
Guest
Posts: n/a
 
      16th Mar 2009
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

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      16th Mar 2009
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
---------------
Jacob Skaria

 
Reply With Quote
 
bijan
Guest
Posts: n/a
 
      16th Mar 2009
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

"Jacob Skaria" wrote:

> 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
> ---------------
> Jacob Skaria
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      16th Mar 2009
You can convert varDate1 to date and then add..

CDate(varDate1) + 180

If this post helps click Yes
--------------
Jacob Skaria
 
Reply With Quote
 
Doug Robbins - Word MVP on news.microsoft.com
Guest
Posts: n/a
 
      16th Mar 2009
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

"bijan" <(E-Mail Removed)> wrote in message
news:97201CC5-3B68-48FD-A8A6-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

« progunta | Enter »
Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Number: 91 object variable or With block Variable not set Hifni Microsoft Excel Programming 1 9th Jan 2008 11:56 AM
add 2 months and a variable number of days to a date =?Utf-8?B?VGltIE5lYWxvbg==?= Microsoft Excel Worksheet Functions 3 1st Oct 2007 05:56 PM
Extract variable number of chars from variable start position? Ann Scharpf Microsoft Excel Worksheet Functions 9 25th Feb 2004 02:10 PM
Re: Year(Number) And Date(Number) input to date range output Wayne Morgan Microsoft Access 0 30th Sep 2003 12:04 AM
Year(Number) And Date(Number) input to date range output Connie Microsoft Access 0 29th Sep 2003 05:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:54 AM.