Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Add Number to variable date

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Add Number to variable date

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Add Number to variable date

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Add Number to variable date

You can convert varDate1 to date and then add..

CDate(varDate1) + 180

If this post helps click Yes
--------------
Jacob Skaria
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Add Number to variable date

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Number: 91 object variable or With block Variable not set Hifni Excel Programming 1 January 9th 08 11:56 AM
add 2 months and a variable number of days to a date Tim Nealon Excel Worksheet Functions 3 October 1st 07 05:56 PM
calc constant date from variable date & return with ability to rn. SusieQ'sQuest Excel Worksheet Functions 1 November 9th 04 08:51 PM
Compare Date in Cell VS a Variable Date to Hide Row JimI Excel Programming 3 October 10th 04 04:26 PM
Using a variable as a Row number Phil Hennessy Excel Programming 3 August 6th 04 05:56 PM


All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"