ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Stored Dates (https://www.excelbanter.com/excel-programming/387832-excel-stored-dates.html)

Trent Argante

Excel Stored Dates
 
I have a UserForm that asks the user to select the year, the month, and the
day.
How do I convert this to an Excel Stored Date without having to write it to
a cell then extract the cell's value via .Formula?
Thanks,
--
Trent Argante
[DC.J(510)]

merjet

Excel Stored Dates
 
Guessing at what you seek, use CLng.

In Immediate Window:
?CLng(#4/20/2007#)
39192

Hth,
Merjet




JE McGimpsey

Excel Stored Dates
 
Take a look at the DateSerial method in XL/VBA Help.

In article ,
Trent Argante wrote:

I have a UserForm that asks the user to select the year, the month, and the
day.
How do I convert this to an Excel Stored Date without having to write it to
a cell then extract the cell's value via .Formula?
Thanks,


Trent Argante[_2_]

Excel Stored Dates
 
Merjet,
You are using literals in CLng(#4/20/2007#).
But how do I use a variable? For Example, CLng(variable).
Thanks,
Trent Argante
[DC.J(510)]

*** Sent via Developersdex http://www.developersdex.com ***

Trent Argante[_2_]

Excel Stored Dates
 
JE,

DateSerial seems only to return standard dates. But, I think I need the
5-digit number that Excel stores behind the scenes so that I can
compare/contrast dates from any country.

Thanks,

Trent Argante
[DC.J(510)]

*** Sent via Developersdex http://www.developersdex.com ***

merjet

Excel Stored Dates
 
Dim dt1 As Date
dt1 = Now
Debug.Print CLng(dt1)

The last line gives 39196 in the Immediate Window.

Hth,
Merjet




All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com