#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default date query

I have dates in the format yyyy-mm-dd. How do I get VB to convert these into
date format? I want to use the dates in a calc to determine the number of
months between 2 dates

eg 2007-06-19 and 1995-09-01


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default date query

Hi,

I'm not exactly sure whether you mean VB or a worksheet function so here's
both. With the earlier date in A1 and the later date in A2 formatted as you
dexcribe right click the sheet tab, view code and paste this in:-

Sub sonic()
MyDifference = DateDiff("M", Range("A1").Value, Range("A2").Value)
End Sub

Or as a workshet function

=DATEDIF(A1,A2,"m")

Mike

"Hilton" wrote:

I have dates in the format yyyy-mm-dd. How do I get VB to convert these into
date format? I want to use the dates in a calc to determine the number of
months between 2 dates

eg 2007-06-19 and 1995-09-01



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default date query

Hi,

The dates are in a text file. There are no dates in the worksheet. The VBA
code can read the date strings but how do I convert them to an acceptable
date format?

"Mike H" wrote in message
...
Hi,

I'm not exactly sure whether you mean VB or a worksheet function so here's
both. With the earlier date in A1 and the later date in A2 formatted as

you
dexcribe right click the sheet tab, view code and paste this in:-

Sub sonic()
MyDifference = DateDiff("M", Range("A1").Value, Range("A2").Value)
End Sub

Or as a workshet function

=DATEDIF(A1,A2,"m")

Mike

"Hilton" wrote:

I have dates in the format yyyy-mm-dd. How do I get VB to convert these

into
date format? I want to use the dates in a calc to determine the number

of
months between 2 dates

eg 2007-06-19 and 1995-09-01





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
Date query Crimson King Excel Worksheet Functions 4 October 24th 07 01:54 AM
Date Query Treza Blu Excel Discussion (Misc queries) 4 May 31st 07 09:11 PM
Query Latest Date Mack Neff Excel Discussion (Misc queries) 1 April 26th 07 07:42 PM
Date query? Harley Excel Discussion (Misc queries) 2 May 11th 06 11:31 AM
How do I enter a date range ie -7 from current date in MS QUERY notsmartenough Excel Discussion (Misc queries) 1 November 11th 05 10:17 PM


All times are GMT +1. The time now is 01:10 PM.

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

About Us

"It's about Microsoft Excel"